Skip to content

feat: support free-threaded CPython 3.14 - #111

Merged
PyYoshi merged 1 commit into
masterfrom
feat/free-threaded-python
Sep 15, 2026
Merged

PyYoshi merged 1 commit into
masterfrom
feat/free-threaded-python

Conversation

@PyYoshi

@PyYoshi PyYoshi commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • declare the Cython extension free-threading compatible so importing it does not re-enable the GIL
  • build and test cp314t wheels on Linux, macOS, and Windows
  • define Py_GIL_DISABLED explicitly for Windows free-threaded builds
  • verify the runtime GIL state in both the test suite and installed-wheel smoke test
  • add a reproducible cChardet-only pyperf benchmark and publish before/after results

The existing Cython nogil regions intentionally remain. Under free-threaded CPython they still detach Python thread state around native-only work, and under regular CPython they are what allows independent detector calls to execute concurrently.

Performance

CPython 3.14.2 free-threaded, preloaded 160-file / 99,819-byte uchardet corpus, rigorous pyperf runs:

Workload Before (module enables GIL) After (GIL stays disabled) Change
Serial corpus 30.6 ms 30.6 ms no significant change
4-thread corpus 9.55 ms 9.25 ms 1.03x faster

Regular CPython 3.14.2 remained effectively unchanged: 30.2→30.3 ms serial and 9.39→9.38 ms with four threads.

Validation

  • free-threaded CPython 3.14t imports with -Werror and leaves sys._is_gil_enabled() false
  • 29 tests pass on CPython 3.11, 3.12, 3.13, 3.14, and free-threaded 3.14t
  • concurrent exact-result stress test covers both detect() and detect_all()
  • Ruff and strict mypy pass
  • a real cp314-cp314t-linux_x86_64 wheel builds, installs into a clean 3.14t uv environment, and passes the wheel smoke test
  • cibuildwheel 4.2.0 selects cp314t identifiers for Linux x86_64/aarch64, macOS x86_64/arm64, and Windows

References

@PyYoshi
PyYoshi marked this pull request as ready for review September 15, 2026 03:35
@PyYoshi
PyYoshi merged commit dcad8ac into master Sep 15, 2026
22 checks passed
@PyYoshi
PyYoshi deleted the feat/free-threaded-python branch September 15, 2026 03:35
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