Repository navigation
Reduce Python formatting allocations and enforce Ruff/Pyright checks - #33
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python str()/repr() currently build an intermediate Rust String before constructing Unicode. Replace all 14 methods with checked stack-buffer formatting and direct PyString returns while preserving textual output. Rust parsing/arithmetic already use borrowed inputs and inline Copy values; a counting-allocator regression test guards these paths. Python output objects still allocate and copy bytes.
Add pinned Ruff 0.16.10 and Pyright 1.1.414 development tools, project configuration targeting Python 3.10, and a dedicated CI job for linting, formatting and type checking all Python source and stubs. Format examples, tests, benchmark and stubs; replace wildcard exports with explicit re-exports. Put native extension declarations in fasttime.pyi and add the comparison operators already supported at runtime. Only missing native implementation-source diagnostics are disabled; missing-import checks remain enabled.
Fix the unix_timestamps example's unsupported DateTime width formatting by using !s and run every example in the Python CI matrix.
Validation:
Local release-wheel formatting microbenchmarks on CPython 3.12/Linux favored stack formatting in both execution orders (~8–33% lower latency across measured cases); shared-host timings vary. Reproduce with python/benchmarks/string_formatting.py.