[Python-Dev] Heap-allocated StructSequences
eelizondo at fb.com
Tue Oct 2 13:09:09 EDT 2018
> We have to assess how 3rd party extension modules would be affected
> by this change.
This change is fully compatible with 3rd party extensions.
The current change to InitType2 is only refactoring, there is no logic change there so that API remains unchanged.
Also, there should not be any instances of PyStructSequence_NewType in use. Any usage of this API causes a crash. A quick Google and Github search show that this is true. Thus, modifying this function should have no conflicts.
A more interesting question would be: "Is the migration of PyStructSequence_InitType2 to PyStructSequence_NewType backwards-compatible?" The answer is yes!
Using gevent as an example (https://github.com/gevent/gevent). This library has a dependency on StatResultType from cpython/Modules/posixmodule.c. This type gets initialized with PyStructSequence_InitType2. After modifying posixmodule.c to use NewType instead of InitType2 gevent still builds and passes all tests. Example: https://github.com/python/cpython/pull/9665
Thus, this change is backwards-compatible by itself and even after migrating to the NewType C-API.
> Converting things to use PyType_FromSpec
> falls in there. As long as the old API still works, these changes should
> go in (but they might need a PEP).
I agree that this change is standalone and should go in by itself. Yet, I'm open to whatever people thing might be the right approach to get this in. i.e: Have more people look at it, writing a PEP, etc.
More information about the Python-Dev