[Cython] Can we remove the FastGIL implementation?

Stefan Behnel stefan_ml at behnel.de
Tue Sep 19 02:56:51 EDT 2023


Hi,

I've seen reports that Cython's "FastGIL" implementation (which basically 
keeps the GIL state in a thread-local variable) is no longer faster than 
CPython's plain GIL implementation in recent Python 3.x versions. 
Potentially even slower. See the report in

https://github.com/cython/cython/issues/5703

It would be helpful to get user feedback on this.

If you have GIL-heavy Cython code, especially with nested 
with-nogil/with-gil sections across functions, and a benchmark that 
exercises it, could you please run the benchmark with and without the 
feature enabled and report the results?

You can add "-DCYTHON_FAST_GIL=0" to your CFLAGS to disabled it (and "=1" 
to enable it explicitly). It's enabled by default in CPython 3.6-3.11 (but 
disabled in Cython 0.29.x on Python 3.11).

Thanks,
Stefan


More information about the cython-devel mailing list