Why GIL?

Hrvoje Niksic hniksic at xemacs.org
Fri Jan 23 14:19:35 EST 2009


Carl Banks <pavlovevidence at gmail.com> writes:

> Unfortunately, references on the stack would need to be registered
> as well, so "PyObject* p;" might have to be replaced with something
> like "Py_DECLARE_REF(PyObject,p);" which magically registers it.
> Ugly.

Not only registered at the beginning of the function, but also (since
CPython uses C, not C++) explicitly unregistered at every point of
exit from the function.  Emacs implements these as macros called GCPRO
and UNGCPRO, and they're very easy to get wrong.  In a way, they are
even worse than the current Python INCREF/DECREF.

See description at, for example,
http://www.xemacs.org/Documentation/beta/html/internals_19.html#SEC78



More information about the Python-list mailing list