[Python-ideas] Simpler Customization of Class Creation - PEP 487
Martin Teichmann
lkb.teichmann at gmail.com
Wed Mar 2 14:43:25 EST 2016
Hi Eric, Hi List,
> Note that I've already been working on making OrderedDict the default
> class definition namespace type. [1] The patch to do so is actually
> super simple (if I remember correctly). This was actually one of my
> main motivations for re-implementing OrderedDict in C (the other was
> preserving the order of **kwargs).
I vaguely remembered your work when I was writing my PEP, but
couldn't find the discussion about it anymore, thanks for pointing me
to it, I'll update that in my PEP.
> Also note that we're thinking along the same lines regarding
> __attribute_order__. :) In the tracker issue I referenced you'll see
> that I proposed roughly the same thing, calling it
> __definition_order__ (which I prefer as the spelling). I've brought
> up the idea a couple of times on this list and got a positive response
> (or so I remember <wink>) and was still planning on pursuing the
> matter in time for Python 3.7.
I agree, __definition_order__ sounds better. I'm not a native speaker,
so I need some help on naming things properly...
> My point is: this part of your proposal stands on its own and is
> already being worked on (even if slowly). FYI, one problem with
> bundling related ideas in a PEP is that the concept of partial
> acceptance isn't a natural part of the PEP process. There have been a
> few PEPs where part of the proposal made the cut but didn't go
> anywhere because the whole PEP was rejected.
I am not very attached to the idea of __definition_order__, so if the
general consensus here is to take it out, I will do that.
In an old version of the PEP (i.e. PEP 422) there was a way to open
the full __prepare__ scheme through the new metaclass. This was certainly
bundling too many ideas in one PEP, so I took that out. I left the
__definition_order__ in as it seemed a very simple idea to me,
especially because once the new metaclass becomes the standard
metaclass, this can be implemented without OrderedDict, and thus
we don't have the need to make OrderedDict a builtin type.
I'm not sure how the general feeling is here on the list: should I
* take out the __definition_order__ and later do the same
with an OrderedDict,
* or should I leave that in because making OrderedDict a
builtin is too much a burden?
I'm looking forward to comments on that!
Btw, how I want to proceed: I am currently looking how other projects
could benefit from PEP 487 (beside my owns...), and got good feedback
from IPython. Then I will implement a version for the standard library.
As a reminder, there is already a version on PyPI:
https://pypi.python.org/pypi/metaclass
Greetings
Martin
More information about the Python-ideas
mailing list