[Python-Dev] PEP 372 -- Adding an ordered directory to collectionsready for pronouncement
Barry Warsaw
barry at python.org
Mon Mar 2 18:02:53 CET 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Raymond,
+1 on adding this to the stdlib. I especially like the idea of being
able to use an ordered dict in a class's namespace. I might be able
use something like that to make my enum package simpler (which
currently requires assignment of the name to the integer sort order).
I wanted to point out that the email package uses an ordered
dictionary in its Message implementation. Messages present a
dictionary-like API for its headers. I don't think I'd be able to use
odicts though for this because of other semantic differences, e.g.
multiple keys are allowed (though only visible through the non-mapping
interface) and KeyError is never raised (like a defaultdict with a
__missing__() returning None). Note though that Message's odict-like
implementation is about as horribly gross as it can be: it's just a
list with linear searching for key lookup. Messages should not have a
billion headers. ;)
Have you or Armin considered the possibility of wanting both the
defaultdict and odict behavior in, say a mixin subclass?
Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQCVAwUBSawRPXEjvBPtnXfVAQIunwQAlty1Gk3EByWK1fwOaN7+X/eC4QN4YpJL
MxWy5l/So3zUM/ofu32kLEjnBLmZOZFp28ExP5QTgse6c0VzNIGP9s6JrZeeAZ7s
uYk+EPChLw2GWuFgLQERpHnX9MA3XpCMbv+SheuqBROs31I7L/TCbDISk3+nOjtA
LngNgWVlKW4=
=glyD
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list