2.6, 3.0, and truly independent intepreters
greg
greg at cosc.canterbury.ac.nz
Sat Oct 25 02:16:59 EDT 2008
Glenn Linderman wrote:
> If Py_None corresponds to None in Python syntax ... then
> it is a fixed constant and could be left global, probably.
No, it couldn't, because it's a reference-counted object
like any other Python object, and therefore needs to be
protected against simultaneous refcount manipulation by
different threads. So each interpreter would need its own
instance of Py_None.
The same goes for all the other built-in constants and
type objects -- there are dozens of these.
> The cost is one more push on every function call,
Which sounds like it could be a rather high cost! If
(just a wild guess) each function has an average of 2
parameters, then this is increasing the amount of
argument pushing going on by 50%...
> On many platforms, there is the concept of TLS, or thread-local storage.
That's another possibility, although doing it that
way would require you to have a separate thread for
each interpreter, which you mightn't always want.
--
Greg
More information about the Python-list
mailing list