[Python-Dev] Heap-allocated StructSequences
Petr Viktorin
encukou at gmail.com
Fri Sep 14 12:04:46 EDT 2018
On 09/13/18 23:34, Neil Schemenauer wrote:
> 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
> issues).
Nope, Victor's fork doesn't include all C-API cleanup. There's an older
long-term effort (PEP-384, PEP-489, the current contenders 576/579/580,
and PEP-573 for the future). 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).
More information about the Python-Dev
mailing list