Lists implemented as integer-hashed Dictionaries?
lists at cheimes.de
Sun Feb 8 14:38:25 EST 2009
Stephen Hansen schrieb:
> Now, I believe Python sets *are* for all intents and purposes
> dictionaries, but I think that's just because its the easiest and most
> efficient way to implement their uniqueness properties; they took the
> very-well-tuned dictionary implementation and cut out the stuff not
> needed by sets and did some tweaks here or there. I /believe/.
You are correct. The first set implementation in pure Python was using a
dict as internal storage. The new set implementation is heavily based on
the highly optimized dict code. Sets are basically dicts without values.
set object implementation
Written and maintained by Raymond D. Hettinger <python at rcn.com>
Derived from Lib/sets.py and Objects/dictobject.c.
More information about the Python-list