Multiple interpreters retaining huge amounts of memory

"Martin v. Löwis" martin at v.loewis.de
Wed Feb 6 13:54:43 EST 2008


 > What objects need to be shared across interpreters?
 >
 > My thought was to add an interpreter number to the PyThreadState
 > structure, to increment it when Py_NewInterpreter is called, and to
 > keep track of the interpreter that creates each object. On deletion,
 > all memory belonging to these objects would be freed.
 >
 > Thoughts?

That won't work, unless you make *massive* changes to Python.
There are many global objects that are shared across interpreters:
Py_None, Py_True, PyExc_ValueError, PyInt_Type, and so on. They
are just C globals, and there can be only a single one of them.

If you think you can fix that, start by changing Python so that
Py_None is per-interpreter, then continue with PyBaseObject_Type.

Regards,
Martin



More information about the Python-list mailing list