[issue29102] Add an id field to PyInterpreterState.

Eric Snow report at bugs.python.org
Fri Dec 30 17:43:16 EST 2016


Eric Snow added the comment:

> What do you think about resetting the counter back to 1 in Py_Initialize?

Sounds good to me.  When I was working on the patch I had the idea in the back of my mind that not resetting the counter would better support interpreter separation efforts in the future.  However, after giving it some thought I don't think that's the case.  So resetting it in Py_Initialize() is fine with me.

> I'll also note that in the threading module, the main thread is
> implicitly thread 0 (but named as MainThread) - Thread-1 is the first
> thread created via threading.Thread. So it may make sense to use a
> signed numeric ID, with 0 being the main interpreter, 1 being the first
> subinterpreter, and negative IDs being errors.

I had considered that and went with an unsigned long.  0 is used for errors, and starting at 1, which effectively means the main interpreter is always 1.  If we later run into overflow issues then we can sort that out at that point (e.g. by moving to a 64-bit int or even a Python int).

I'll add comments to the patch regarding these points.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29102>
_______________________________________


More information about the Python-bugs-list mailing list