Skip to content

Conversation

@beer-psi
Copy link

@beer-psi beer-psi commented Dec 25, 2025

What are you trying to accomplish?

With the release of Python 3.14, free-threading is no longer considered experimental, and many packages are now being updated to support free-threaded Python. I'd like for ciso8601 to support free-threaded Python.

Related issue: #175

What approach did you choose and why?

Most of the library code is already stateless and re-entrant, so not many changes were needed. The one global state, tz_cache, is now guarded by a PyMutex in the free-threaded build.

Testing was done on unittest-ft to spot any potential failures from race conditions, and there didn't seem to be any.

What should reviewers focus on?

Potential thread safety issues I've missed. I've had Gemini look it over, but I still worry I missed something, since this is my first time looking at the library's code.

The impact of these changes

There is a minor performance penalty associated with synchronizing access to tz_cache. On the timestamp with timezone benchmark, Python 3.14t performs slightly worse than Python 3.14 (69.7ns vs 66.4ns). This is still better than not caching at all (~80ns). There didn't seem to be any impact when parsing timestamps without timezone.

Testing

tox.ini has already been updated to use unittest-ft, so testing the new changes should just be running tox.

On Windows, the Py_GIL_DISABLED macro is not defined automatically, but must be specified
to the compiler when building.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant