On 21 June 2016 at 06:12, Guido van Rossum <gu...@python.org> wrote: > 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?) >
Although not a Jython developer, I've looked into the code a few times. The major stumbling block as I understand it will be that Jython uses a ConcurrentHashMap as the underlying structure for a dictionary. This would need to change to a concurrent LinkedHashMap, but there's no such thing in the standard library. The best option would appear to be https://github.com/ben-manes/concurrentlinkedhashmap. There are also plenty of other places that use maps and all of them would need to be looked at. In a lot of cases they're things like IdentityHashMap which may also need an ordered equivalent. There is a repo for Jython 3.5 development: https://github.com/jython/jython3 but it doesn't seem to be very active - only 11 commits in the last year (OTOH that's also in the last 3 months). Tim Delaney
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com