Skip to content

Add support for free-threaded Python (PEP 703)#952

Open
Gaganraj2002 wants to merge 1 commit intopython-pendulum:masterfrom
Gaganraj2002:free-threaded-support
Open

Add support for free-threaded Python (PEP 703)#952
Gaganraj2002 wants to merge 1 commit intopython-pendulum:masterfrom
Gaganraj2002:free-threaded-support

Conversation

@Gaganraj2002
Copy link

Builds on #940 — this completes the remaining work for free-threaded Python support.

Changes

Rust (rust/src/python/mod.rs):

  • Add gil_used = false to #[pymodule] declaration (PyO3 0.27 defaults to true)
  • The Rust codebase has zero global mutable state, zero unsafe blocks, and zero static variables — all functions are pure computations, making it inherently thread-safe

Test workflow (.github/workflows/tests.yml):

  • Add 3.13t and 3.14t to the test matrix
  • Skip mypy/typing dependencies for free-threaded builds (not yet compatible)

Release workflow (.github/workflows/release.yml):

  • Add a free-threaded wheel build step (--interpreter 3.13t 3.14t) in the build job
  • Skipped for PyPy matrix entries

Tests:

  • Add tests/test_thread_safety.py with concurrent stress tests for parse, now, duration, diff, and format (8 threads x 200 iterations each)

Test plan

  • All 5 thread-safety tests pass locally
  • Builds successfully with maturin on CPython 3.13
  • CI: Tests pass on 3.13t and 3.14t
  • CI: Free-threaded wheels build across all platforms

Builds on python-pendulum#940 — completes the remaining work for free-threaded support.

Rust:
- Add `gil_used = false` to `#[pymodule]` (PyO3 0.27 defaults to true)
- Codebase has zero global state, zero unsafe — all functions are pure

CI (tests.yml):
- Add 3.13t and 3.14t to test matrix
- Skip mypy/typing deps for free-threaded builds (not yet compatible)

CI (release.yml):
- Add free-threaded wheel build step (3.13t/3.14t) in the build job
- Skipped for PyPy matrix entries

Tests:
- Add concurrent thread-safety tests for parse, now, duration, diff, format
@Gaganraj2002 Gaganraj2002 mentioned this pull request Mar 22, 2026
2 tasks
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