[Python-Dev] PEP 487: Simpler customization of class creation

Guido van Rossum guido at python.org
Mon Jun 20 16:12:08 EDT 2016


OK, basically you're arguing that knowing the definition order of class
attributes is often useful when (ab)using Python for things like schema or
form definitions. There are a few ways to go about it:

1. A hack using a global creation counter
<https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/master/ndb/model.py#L888>
2. Metaclass with __prepare__
<https://docs.python.org/3/reference/datamodel.html#prepare>
3. PEP 520 <https://www.python.org/dev/peps/pep-0520/>
4a. Make all dicts OrderedDicts in CPython
<http://bugs.python.org/issue27350>
4b. Ditto in the language standard

If we can make the jump to (4b) soon enough I think we should skip PEP 520;
if not, I am still hemming and hawing about whether PEP 520 has enough
benefits over (2) to bother.

Sorry Eric for making this so hard. The better is so often the enemy of the
good. I am currently somewhere between -0 and +0 on PEP 520. I'm not sure
if the work on (4a) is going to bear fruit in time for the 3.6 feature
freeze <https://www.python.org/dev/peps/pep-0494/#schedule>; if it goes
well I think we should have a separate conversation (maybe even a PEP?)
about (4b). Maybe we should ask for feedback from the Jython developers?
(PyPy already has this IIUC, and IronPython
<https://github.com/IronLanguages/main> seems moribund?)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20160620/e3cfdf44/attachment.html>


More information about the Python-Dev mailing list