[Haskell-cafe] implementing python-style dictionary in Haskell
dave at zednenem.com
Tue Nov 18 12:37:14 EST 2008
2008/11/18 kenny lu <haskellmail at gmail.com>:
> Here is a comparison of memory usage
> Map : 345 MB
> IntMap : 146 MB
> Trie : 282 MB
> Python : 94 MB
> Here is a comparison of execution time (on an intel dual core 2.0G)
> Map: 26 sec
> IntMap: 9 sec
> Trie: 12 sec
> Python: 2.24 sec
> The above number shows that my implementations of python style dictionary
> are space/time in-efficient as compared to python.
> Can some one point out what's wrong with my implementations?
This isn't really a fair comparison. Map, IntMap, and Trie are
persistent data structures, and Python dictionaries are ephemeral.
(That is, when you "add" a key to a Map, you actually create a new one
that shares structure with the old one, and both can be used in
subsequent code. In Python, you would have to copy the dictionary.)
Dave Menendez <dave at zednenem.com>
More information about the Haskell-Cafe