AA performance again
bearophile
bearophileHUGS at lycos.com
Mon Jun 9 10:19:32 PDT 2008
Steven Schveighoffer:
> Have you tried dcollections HashMap?
> www.dsource.org/projects/dcollections
Not yet, I may try them later.
> On my box (don't have python installed), 10m inserts took 15.3s, and the
> memory usage was 290MB (I think :) )
If you want, there are "mobile" versions of Python that doesn't require an installation.
I may want to ask you what's your CPU/clock.
> Of course, the python numbers are much better, but the issue basically comes
> down to when you allocate more memory, the GC tries to run and free some up
> too often. There's not a lot I can do about that.
I don't think it's just a matter of memory allocator (but I have no proof of this), there are many different macro and subtle ways to implement an hash map in C.
Two more things:
- In my blog post I have added a third Python version that's better, it creates a true dict (AA):
dict.fromkeys(xrange(20000000), 0)
- I have used D longs because Python ints are like that (Python 2.5 uses multiprecision numbers later), but Python integers are objects (so they are "boxed"). Inside sets and dicts their memory usage for Python 2.5 is:
set(int): 28.2 byte/element
dict(int:None): 36.2 byte/element
Thank you for your answer,
bear hugs,
bearophile
More information about the Digitalmars-d
mailing list