Floats as keys in dict

Brian Elmegaard brian at rkspeed-rugby.dk
Wed Aug 1 05:40:33 EDT 2007


Hi

I am making a script to optimiza by dynamic programming. I do not know
the vertices and nodes before the calculation, so I have decided to
store the nodes I have in play as keys in a dict.

However, the dict keys are then floats and I have to round the values
of new possible nodes in each step. When profiling I see that the most
time consuming part of my script is rounding.

Is there a faster way than round() or is there a better way to test
than 'in' or should I store the keys in another way than a dict?

tia,
-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk



More information about the Python-list mailing list