Add an optional native parser backend with pure-Python fallback - #694
Open
lowmiaq-gmail wants to merge 3 commits into
Open
Add an optional native parser backend with pure-Python fallback#694lowmiaq-gmail wants to merge 3 commits into
lowmiaq-gmail wants to merge 3 commits into
Conversation
Author
|
Update: the backend-only distribution is now publicly available as fast-dotenv-rs-backend 0.1.1. The release workflow built and audited 5 platform wheels plus an sdist; the publish job succeeded, and fresh public PyPI install/coexistence/native-call checks pass locally. Evidence run: https://github.com/lowmiaq-gmail/fast-dotenv-rs/actions/runs/33084678870. The PR remains default-off: without the optional backend, python-dotenv stays on the existing pure-Python parser. |
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.
Problem
Some parse-heavy consumers of
python-dotenvcan spend measurable time in the parser, while the default package must remain pure Python and portable.Proposal
Add a small optional adapter at the parser boundary:
pip install python-dotenvremains the current pure-Python path.pip install "python-dotenv[native]"opts intofast-dotenv-rs-backendon CPython.BindingandOriginalobjects.The backend-only distribution does not install
dotenvor a console script, so it can coexist with this package. The Rust implementation and wheels are maintained separately in fast-dotenv-rs.Compatibility
The patch is based on upstream main at
a00cb2eed0704cd6d2071b2004c37e95ccc86ee5and only changes the parser boundary plus the optional extra. ExistingBinding,Original,parse_stream, CLI, and fallback behavior remain the public contract.Local validation:
263 passed, 1 skippedin an isolated CPython 3.14 environment; one unrelated macOSprintenv --versionfixture differs from Linux behavior.Performance evidence
In the real-consumer benchmark, 21/30 p50 rows improved, 8 were neutral, and 1 small cold-start CLI row regressed. Representative absolute savings were approximately 0.13 ms for a small
dotenv_valuesworkload, 0.75 ms for medium input, and 4.94 ms for large input. The adapter is intentionally optional because small cold-start workloads are not universally faster.Maintenance and rollback
This is the concrete implementation for #693; the backend-only package release is being completed independently so that the upstream package does not need to own a Rust build pipeline.