Skip to content

Fix lossless pickle support for DateTime and Duration - #35

Merged
egorsmkv merged 2 commits into
masterfrom
fix/34-pickle-datetime-duration
Oct 15, 2026
Merged

egorsmkv merged 2 commits into
masterfrom
fix/34-pickle-datetime-duration

Conversation

@egorsmkv

@egorsmkv egorsmkv commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

pickle.dumps() raises TypeError for fasttime.DateTime and fasttime.Duration. Add PyO3 __reduce__ methods that restore values through existing public constructors: integer i128 nanoseconds for Duration, and whole Unix seconds plus a nonnegative nanosecond component for DateTime. This preserves nanosecond precision and negative timestamps without float conversion or mutable restore state.

Closes #34.

Changes:

  • Add regression tests in a separate first commit; reproduce both failures before implementing the fix.
  • Cover protocols 0–5, default and -1; i128 duration limits; i32 year limits; year zero and leap days; -1 ns; equality, hashes, dictionary/set membership; clean-process reconstruction; and shared-instance thread use.
  • Update type stubs and Python documentation.
  • Extend Linux CI to Python 3.15, 3.14t and 3.15t, checking that importing the extension keeps the GIL disabled. Existing Windows wheel tests also exercise the regressions.

Validation:

  • All 200 Python tests pass locally on CPython 3.10.22, 3.12.14, 3.14.8t and 3.15.0rc3t. Both free-threaded interpreters retain the disabled GIL.
  • Rust tests pass with default features, no default features and the Python feature (20 tests in each configuration; Python-feature Rust tests use CPython 3.10).
  • Rust formatting, Clippy including Python bindings, Ruff lint/format, Pyright and all five Python examples pass.
  • Test workflow: successful, including all eight Linux Python configurations (3.10–3.15, 3.14t, 3.15t), Rust and quality checks.
  • Python distribution workflow: all eight Windows wheel build/tag/test jobs successful, including 3.14t and 3.15t. Release-only jobs are skipped for pull requests.

@egorsmkv
egorsmkv merged commit c1f8673 into master Oct 15, 2026
24 checks passed
@egorsmkv
egorsmkv deleted the fix/34-pickle-datetime-duration branch October 15, 2026 15:52
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.

Cannot pickle DateTime nor Duration objects

1 participant