[Python-Dev] Heap-allocated StructSequences

Neil Schemenauer nas-python at arctrix.com
Fri Sep 14 02:34:59 EDT 2018

On 2018-09-04, Eddie Elizondo wrote:
> Solution:
>   *   Fix the implementation of PyStructSequence_NewType:
> The best solution would be to fix the implementation of this
> function. This can easily be done by dynamically creating a
> PyType_Spec and calling PyType_FromSpec

Hello Eddie,

Thank you for spending time to look into this.  Without studying the
details of your patch, your approach sounds correct to me.  I think
we should be allocating types from the heap and use PyType_FromSpec.
Having static type definitions living in the data segment cause too
many issues.

We have to assess how 3rd party extension modules would be affected
by this change.  Unless it is too hard to do, they should still
compile (perhaps with warnings) after your fix.  Do you know if
that's the case?  Looking at your changes to structseq.c, I can't
tell easily.

In any case, this should go into Victor's pythoncapi fork.  That
fork includes all the C-API cleanup we are hoping to make to CPython
(assuming we can figure out the backwards and forwards compatibility

Here is the project site:




More information about the Python-Dev mailing list