sorteddict PEP proposal [started off as orderedict]

Raymond Hettinger python at rcn.com
Wed Sep 26 22:06:36 CEST 2007


[James Stroud ]
> Maybe its the PEP killers who act prematurely because I friggin' love
> genexps and the little generators they generate.

No, it's the PEP author who controls when they ask for pronouncement.
The natural instinct is to ask for pronouncement as soon as you have
an implementation and a couple of advocates, but the smarter play is
to put the code in the wild and let it mature so that the kinks get
worked out, a fan club can grow, the patterns of usage become
established, and acceptance/rejection becomes self-evident.

Genexps got hung-up on details like whether the loop variable should
be visible (like it is with list comps), was it faster or slower than
list comps (unknown until an implementation was provided), could it be
fit into the grammar unambiguously (the answer was yes *after*
introducing a requirement for enclosing parentheses in some cases).
Also, there were some cases that had (and still have) surprising
behaviors -- in the end, those were addressed by adding advice to
consumer genexps right away and not pass them around like regular
generators where the scoping was more self-evident.

The other disadvantage of asking for pronouncement prematurely is the
risk that everyone gives it a nod without deep thought about whether
it is truly necessary and useful.  I got dict.fromkeys() accepted
without much fuss but now am now sure it was a good idea -- it added
to an already heavy dict API but did not offer compelling usability
advantages or performance advantages.  Had the set() builtin already
been in place, it is much less likely that dict.fromkeys would have
been accepted.


Raymond




More information about the Python-list mailing list