Dictionary .keys() and .values() should return a set [withPython3000 in mind]

Delaney, Timothy (Tim) tdelaney at avaya.com
Mon Jul 3 17:20:56 EDT 2006


Paul Rubin wrote:

> "cmdrrickhunter at yaho.com" <conrad.ammon at gmail.com> writes:
>> And a "view" of the dictionary is orders faster than creating a copy
>> of it (which is required to keep k0 from changing in your example). 
>> If you're LUCKY, copying a dictionary is O(n),
> 
> There are ways to do it so you don't have to copy, but the dict would
> then no longer be a straightforward hash table.

Plus copy-on-write isn't something you want in general - it's *much*
slower since it needs to copy the internal data every time it's
modified. The vast majority of uses of data structures does not involve
concurrent modification.

Tim Delaney



More information about the Python-list mailing list