Robert Bradshaw wrote: > On Wed, 2 Sep 2009, Christopher Barker wrote: > >> Sanne Korzec wrote: >>> The main bottleneck in my code is a large dictionary / hash table which >>> I would like to optimize. >> In what way do you need to optimize it? i.e. how is it used? do you have >> memory issues or speed issues? python dicts are highly optimized >> already, so you're not likely to do much better with the look-up speed. > > It could help with both memory and speed. In particular, to do a lookup in > a Python hashtable you need to > > (1) Wrap the float in a Python object > (2) call __hash__ on that new object
I hope that isn't what actually happens :-) Floating point and hashes don't seem like a good idea. (Just a note, I believe the OP was talking about floats in the values so we're good.) > (3) actually do the lookup > (4) unwrap the result back into a float. > > Python does have a highly optimized (3), but the overhead for the rest > will probably overwhelm it speedwise, so I bet a simple, unwrapped > implementation would still be quite a win. > > - Robert > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
