Access dictionary in order?

Diego Dainese ddainese97x at x18dsi.unive.it
Mon Jul 26 05:00:19 EDT 1999


On Sun, 25 Jul 1999 12:22:03 -0500 (CDT), Skip Montanaro wrote:
> You demonstrated the best way.  There is no need to save the key list unless
> the dictionary is very large though.  Just grab 'em and sort 'em when you
> need:
> 
>     keylist = dict.keys()
>     keylist.sort()
>     for key in keylist: do_stuff(dict[key])
> 

But how much time requires the keylist generation?

That is, the keylist is made traversing all the dictionary nodes or is
cached inside it?

-- 
Diego Dainese
--
To reply remove the numbers and the `x' from my address
--
Sorry for my bad English!




More information about the Python-list mailing list