3 ms·
They're moving towards standardizing the ordered dict layout https://docs.python.org/3/library/inspect.html https://docs.python.org/3/library/inspect.html PyP
by __s 9y ago
They're moving towards standardizing the ordered dict layout
https://docs.python.org/3/library/inspect.html https://docs.python.org/3/library/inspect.html
PyPy has a glue layer to implement the C API. The C API is designed around reference counting, which PyPy doesn't do. This also shows up in Python code assuming files will be immediatly closed in lines like 'x = open(fname).read()'
Method resolution order. __slots__. globals(). id
- orf 9y agoOk, fair enough, thanks for providing some examples, but I'm not sure how many are valid though (Don't get me wrong, there are a bunch, the main one being reliance on the GC/ref count semantics). > They're moving towards standardizing the ordered dict layout Can you elaborate? Not sure what you mean. > inspect library Yes, a fair few functions in that module are CPython specific (or assume a CPython-ish runtime). > C API Isn't the C API CPython specific? It is not a Python-language feature. PyPy implemented it to drive up adoption. How would the C API be expected to work with Jython, or IronPython, or a JS implementation? > Method resolution order This is not a CPython leaking, it's a specified thing. Python uses the C3 algorithm. > __slots__ Again, this is a language (or object model) feature? > globals() Again, specified by the language? Not a CPython specific thing? > id ID returns a unique identifier per object. That's all, in CPython it returns the memory address. Is that what you mean? --- There are also only 5 'CPython implementation detail' warnings in the language data model docs[1] 1. https://docs.python.org/3.6/reference/datamodel.html https://docs.python.org/3.6/reference/datamodel.html
- chrisseaton 9y ago> Isn't the C API CPython specific? It is not a Python-language feature. But the Python ecosystem depends on extensions written using the C API. If you are trying to write a new Python implementation and they tell you they need to be able to run some C extension you can tell them 'actually that's a CPython feature' all you want, but they'll go away and not use your implementation. > How would the C API be expected to work with Jython, or IronPython, or a JS implementation? Well you'd implement the same API using JNI, PlatformInvoke, or the V8 C extension API, or whatever else the platform you are building on has, respectively. But it's hard!
- __s 9y agoCalling __slots__ a language/object feature is a crutch. It was made a language feature based on how CPython implements objects with a __dict__ field showing the backing dictionary. Also there's the 'is' operator which has unspecified behavior with integers/strings due to integer-cache & string interning. If you used unboxed integers then 'is' would likely work as equals for all integers that weren't bignums. Python's tried to define a standard outside CPython's details, but CPython is essentially de facto, so for serious implementations it's details are important to follow. Similar thing happened with clang needing to implement many GCC C extensions Ordered dict layout: https://mail.python.org/pipermail/python-dev/2016-September/146489.html https://mail.python.org/pipermail/python-dev/2016-September/...