[Python-ideas] Remove GIL with CAS instructions?

Guido van Rossum guido at python.org
Tue Nov 24 20:10:14 CET 2009

Note that Greg Stein reached this same conclusion (and similar
numbers) over 10 years ago...

On Tue, Nov 24, 2009 at 10:39 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Ok, out of curiousity I gave it a try: replacing INCREF/DECREF with atomic
> instructions (*) slows down the interpreter by 20 to 40% depending on the
> workload. And keep in mind this is the tip of the iceberg: to remove the GIL
> you'd also have to add fine-grained locking in other places (dicts etc.).
> Which makes me agree with the commonly expressed opinion that CPython would
> probably need to ditch refcounting (at least in the critical paths) if we want
> to remove the GIL.
> Regards
> Antoine.
> (*) using gcc's atomic primitives which, I have checked, are inlined as
> carefully optimized assembler:
> http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list