Why GIL?

Paul Rubin http
Sat Jan 24 09:43:23 CET 2009

Hrvoje Niksic <hniksic at xemacs.org> writes:
> 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.

That's a fairly natural style in Lisp implementation and it is not
that difficult to code in.  I've hacked inside Emacs and have written
another interpreter with a similar setup; it's certainly easier than
keeping track of refcounts in my experience.  For one thing, you can
raise exceptions anywhere you want, and the stack unwind can clean up
the gc protection, but it can't know nearly as easily which refcounts
to adjust, unless you record all the increfs the same way as the

More information about the Python-list mailing list