[Python-Dev] multiple interpreters and extension modules

"Martin v. Löwis" martin at v.loewis.de
Sat Dec 30 02:19:12 CET 2006


Jeremy Kloth schrieb:
> 1) is subclassing Python classes in C as a static type supported? Even if they 
> would be declared on the heap, they would be bound to the first loaded Python 
> class.

As you found out: no, this isn't supported.

To work around, you can wrap the extension module with Python module
which invokes an explicit module initialization function; you then need
to lookup the subclasses dynamically (going through
thread_state->interp->modules).

> As to question 2, I'm in the process of prototyping that approach to see if it 
> is feasible in our code and if so, (and people find it useful) I'll attempt 
> to write a PEP for that feature.

I'd like to see the module initialization/finalization be redone for
Python 3, in particular with explicit finalization procedures. If
Python 3 still supports multiple interpreters, this aspect should be
taken into account. Whether there is any chance to add the PEP to 2.x,
I don't know - it needs to be written first.

Regards,
Martin


More information about the Python-Dev mailing list