Anyway to clarify this code? (dictionaries)

Steven D'Aprano steve at REMOVEMEcyber.com.au
Wed Nov 23 02:52:33 EST 2005


javuchi wrote:

> I want to avoid converting the dictionary to a list and then to a
> dictionay. Are there speed penalties for such a conversion?

You mean, is it faster to write, test, debug and 
execute slow Python code rather than letting Python's 
built-in routines written in fast C do the job?

I have no idea. Perhaps you should try it and see. 
Write some code to do it all manually, and time it.

Make sure you use realistic test data: if your users 
will be using dictionaries with 10,000 items, there is 
no point in testing only dictionaries with 10 items. 
For accuracy, run (say) 20 tests, and look at the 
average speed. Of better still, use the timeit module.



-- 
Steven.




More information about the Python-list mailing list