[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/12/21 8:23 PM, Neil Schemenauer wrote: On 2021-01-12, Pablo Galindo Salgado wrote: One worry that I have in general with this move is the usage of _PyType_GetModuleByDef to get the type object from the module definition. This normally involves getting a TLS in every instance creation,

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Neil Schemenauer
On 2021-01-12, Petr Viktorin wrote: > Unfortunately, it's not just the creation that needs to be changed. > You also need to decref Foo_Type somewhere. Add the type to the module dict? ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Neil Schemenauer
On 2021-01-12, Pablo Galindo Salgado wrote: > One worry that I have in general with this move is the usage of > _PyType_GetModuleByDef to get the type object from the module > definition. This normally involves getting a TLS in every instance > creation, which can impact notably performance for

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Nelson, Karl E. via Python-Dev
to evaluating the address of the heap type. But that is just my 2 cents. --Karl -Original Message- From: Neil Schemenauer Sent: Tuesday, January 12, 2021 10:17 AM To: Victor Stinner Cc: Python Dev Subject: [Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Antoine Pitrou
On Tue, 12 Jan 2021 18:48:39 + Pablo Galindo Salgado wrote: > One worry that I have in general with this move > is the usage of _PyType_GetModuleByDef to get the type object > from the module definition. This normally involves getting a TLS in every > instance creation, > which can impact

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/12/21 7:48 PM, Pablo Galindo Salgado wrote: One worry that I have in general with this move is the usage of _PyType_GetModuleByDef to get the type object from the module definition. This normally involves getting a TLS in every instance creation, Not TLS, it's walking the MRO. which

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/12/21 7:16 PM, Neil Schemenauer wrote: On 2021-01-12, Victor Stinner wrote: It seems like a safer approach is to continue the work on bpo-40077: "Convert static types to PyType_FromSpec()". I agree that trying to convert static types is a good idea. Another possible bonus might be that

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Pablo Galindo Salgado
One worry that I have in general with this move is the usage of _PyType_GetModuleByDef to get the type object from the module definition. This normally involves getting a TLS in every instance creation, which can impact notably performance for some perf-sensitive types or types that are created a

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Neil Schemenauer
On 2021-01-12, Victor Stinner wrote: > It seems like a safer approach is to continue the work on > bpo-40077: "Convert static types to PyType_FromSpec()". I agree that trying to convert static types is a good idea. Another possible bonus might be that we can gain some performance by integrating

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/12/21 4:34 PM, Antoine Pitrou wrote: On Tue, 12 Jan 2021 15:22:36 +0100 Petr Viktorin wrote: On 1/11/21 5:26 PM, Victor Stinner wrote: Hi, There are multiple PEPs covering heap types. The latest one refers to other PEPs: PEP 630 "Isolating Extension Modules" by Petr Viktorin.

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/12/21 4:09 PM, Victor Stinner wrote: On Tue, Jan 12, 2021 at 3:28 PM Petr Viktorin wrote: If a type is immutable and has no references to heap-allocated objects, it could stay as a static type. The issue is that very many types don't fit that. For example, if some method needs to raise

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Antoine Pitrou
On Tue, 12 Jan 2021 15:22:36 +0100 Petr Viktorin wrote: > On 1/11/21 5:26 PM, Victor Stinner wrote: > > Hi, > > > > There are multiple PEPs covering heap types. The latest one refers to > > other PEPs: PEP 630 "Isolating Extension Modules" by Petr Viktorin. > >

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Victor Stinner
On Tue, Jan 12, 2021 at 3:28 PM Petr Viktorin wrote: > If a type is immutable and has no references to heap-allocated objects, > it could stay as a static type. > The issue is that very many types don't fit that. For example, if some > method needs to raise a module-specific exception, that's a

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread encukou
Simon Cross wrote: > We've run into some minor issues with the limitations in PyType_Slot > (https://docs.python.org/3/c-api/type.html#c.PyType_Slot.PyType_Slot.slot) > but we are working around them for the moment. > It would be useful to have some sense of where PyType_FromSpec is > headed --

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-12 Thread Petr Viktorin
On 1/11/21 5:26 PM, Victor Stinner wrote: Hi, There are multiple PEPs covering heap types. The latest one refers to other PEPs: PEP 630 "Isolating Extension Modules" by Petr Viktorin. https://www.python.org/dev/peps/pep-0630/#motivation The use case is to embed multiple Python instances

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-11 Thread Victor Stinner
Hi, There are multiple PEPs covering heap types. The latest one refers to other PEPs: PEP 630 "Isolating Extension Modules" by Petr Viktorin. https://www.python.org/dev/peps/pep-0630/#motivation The use case is to embed multiple Python instances (interpreters) in the same application process, or

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-11 Thread Simon Cross
Hi Victor, Thank you for looking into these issues. They are very important to HPy too! HPy currently only supports head types for similar reasons to why they are important to sub-interpreters -- their lifecycle can be managed by the Python interpreter and they are not tied to the memory and

[Python-Dev] Re: Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-01-09 Thread Antoine Pitrou
On Sat, 9 Jan 2021 02:02:17 +0100 Victor Stinner wrote: > > It's an hard problem and I don't see any simple/obvious solution right > now, except of *workarounds* that I dislike. Maybe the only good > solution is to fix all heap types, one by one. Ok. Why are we adding heap types to the stdlib