4 ms·
Ok, 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 relia
by orf 9y ago
Ok, 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/...