Why is dictionary.keys() a list and not a set?

bonono at gmail.com bonono at gmail.com
Thu Nov 24 02:01:23 EST 2005


Fredrik Lundh wrote:
> performance is of course another aspect; if you *need* two parallel
> lists, creating a list full of tuples just to pull them apart and throw
> them all away isn't exactly the most efficient way to do things.
>
> (if performance didn't matter at all, we could get rid most dictionary
> methods; "iterkeys", "in", and locking should be enough, right?)
If I need two parallel list(one key, one value), I can still use  the
same [(k,v)] tuple, just access it as x[0], x[1].

But the history alone explains it anyway.




More information about the Python-list mailing list