imagecodecs icon indicating copy to clipboard operation
imagecodecs copied to clipboard

Add Cython flag to signal free-threading compatibility

Open lysnikolaou opened this issue 1 year ago • 2 comments

These are the necessary changes for imagecodecs to signify that it's compatible with the Python 3.13 free-threaded build. I've run some tests and everything seems to be running fine with it, apart from the issue described in #112.

lysnikolaou avatar Oct 03 '24 13:10 lysnikolaou

Thanks. I'll reconsider this when ready to test free-threading. It's probably better to enable freethreading_compatible per module after individual review and testing. The criteria for freethreading_compatible must be stricter than passing existing tests without crash, no?

cgohlke avatar Oct 03 '24 16:10 cgohlke

A thing to note is that the GIL is dynamically enabled for the whole process even if there's just one extension module that does not set the freethreading_compatible flag. That's why we've been pretty aggressive in enabling the freethreading_compatible flag, since that enables testing for bigger codebases that include many dependencies.

Also, I'm happy to spend more time on this and do any testing you'd like to see. Apart from running the tests, I did a manual skim through the code as well, but that's always going to miss some stuff.

lysnikolaou avatar Oct 04 '24 08:10 lysnikolaou

Thanks again. This will be in the next release, which requires Cython 3.1. Imagecodecs and tifffile tests pass on my Windows system with Python 3.13t.

cgohlke avatar Apr 04 '25 19:04 cgohlke

Testing with pytest-run-parallel has identified a few places, which need to be wrapped with cython.critical_section.

cgohlke avatar Apr 05 '25 19:04 cgohlke