Skip to main content

fast-dotenv-rs

CI PyPI Python 3.10+ Rust License

A fast Rust-backed drop-in replacement for python-dotenv==1.2.2, built with PyO3 and Maturin. It preserves the dotenv Python API, CLI, IPython extension, interpolation rules, and file mutation behavior.

中文说明

from dotenv import dotenv_values, load_dotenv

load_dotenv()
config = dotenv_values(".env")

The distribution is named fast-dotenv-rs, but existing application code keeps importing dotenv.

Why this project

  • Low migration cost: keep from dotenv import load_dotenv and the dotenv CLI.
  • Verifiable compatibility: run the complete pinned python-dotenv==1.2.2 upstream suite, not only basic KEY=value examples.
  • Reproducible performance evidence: compare candidate and Oracle in isolated processes and validate values, types, and ordering before timing.
  • Cross-platform packaging: build abi3 wheels with PyO3 and Maturin.

Status

Version 0.1.1 is the formal-release line. It makes Click a default dependency so a plain public install provides the complete dotenv CLI. The release workflow builds five native wheels and one sdist, publishes that immutable set through Trusted Publishing, then reinstalls the base public package and passes the full upstream compatibility suite on every advertised platform before creating the formal GitHub Release. Until those public links exist, the release remains blocked.

GitHub Actions CI #3 passed all four jobs:

Platform Python Installed-wheel verification
Linux x86-64 3.10 and 3.12 Rust gates, project tests, 10,000-case differential gate, full upstream suite, artifact audit
macOS arm64 3.12 wheel install, CLI, 219 upstream tests passed
Windows x86-64 3.12 wheel install, CLI, 169 passed / 50 upstream platform skips

The local Linux x86-64 / CPython 3.12 upstream result is:

218 passed, 1 skipped, 0 failed

The single Linux skip is an upstream platform/root condition. IPython was installed, so all three upstream IPython tests ran.

Installation

After the 0.1.1 public release exists, install the package with:

python -m pip install "fast-dotenv-rs==0.1.1"

Application code continues importing dotenv. To build from source instead:

git clone https://github.com/lowmiaq-gmail/fast-dotenv-rs.git
cd fast-dotenv-rs
python -m venv .venv
source .venv/bin/activate       # Windows: .venv\Scripts\activate
python -m pip install -U pip maturin
maturin develop --release

Build a wheel:

maturin build --release --out wheelhouse
python -m pip install wheelhouse/*.whl

Do not install the Oracle in the same environment

Both python-dotenv and this project provide the top-level dotenv package and the dotenv command. Installing both in one environment causes the last installed distribution to overwrite the other. Use separate virtual environments for candidate/Oracle comparisons.

Compatible surface

Top-level exports match python-dotenv==1.2.2:

from dotenv import (
    dotenv_values, find_dotenv, get_cli_string, get_key,
    load_dotenv, load_ipython_extension, set_key, unset_key,
)

The compatibility surface also includes:

  • dotenv.main.DotEnv, rewrite, and resolve_variables;
  • parser Binding, Original, Reader, Position, and parser functions;
  • variable Atom, Literal, Variable, and parse_variables;
  • CLI list, set, get, unset, and run;
  • dotenv.ipython.IPythonDotEnv and the %dotenv magic.

See docs/UPSTREAM-CONTRACT.md for signatures, return values, logging, exceptions, filesystem effects, and environment behavior.

CLI

dotenv list
dotenv list --format=json
dotenv set DATABASE_URL 'postgres://localhost/app'
dotenv get DATABASE_URL
dotenv unset DATABASE_URL
dotenv run -- python app.py
python -m dotenv --version

Reproduce the compatibility gates

python -m pip install "pytest>=8,<9" "click>=5" "ipython>=8"
cargo test --all-targets
PYTHONPATH=python python -m pytest -q tests
bash scripts/run_upstream_full.sh
PYTHONPATH=python python scripts/run_differential.py

The upstream runner pins and verifies the official python-dotenv==1.2.2 sdist and every upstream test fixture hash. It also checks that the candidate, not an installed Oracle, owns the imported dotenv namespace.

Benchmark snapshot

On one Linux x86-64 / CPython 3.12 machine, isolated-process dotenv_values() in-memory parsing workloads measured 15.957×–88.609× faster. The harness checks the return type, item order, and values before timing.

python tests/benchmark.py --repeats 7 --warmup 2 --iterations 1000

These numbers do not represent file I/O, process startup, macOS, Windows, or every application workload. See BENCHMARK.md for inputs, raw context, and limitations.

Documentation

License

Rust/PyO3 project code is MIT licensed. BSD-3-Clause notices for the upstream compatibility baseline are recorded in THIRD_PARTY_NOTICES.md and licenses/.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_dotenv_rs-0.1.1.tar.gz (787.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fast_dotenv_rs-0.1.1-cp310-abi3-win_amd64.whl (136.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (230.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (223.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fast_dotenv_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (207.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fast_dotenv_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (214.1 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file fast_dotenv_rs-0.1.1.tar.gz.

File metadata

  • Download URL: fast_dotenv_rs-0.1.1.tar.gz
  • Upload date:
  • Size: 787.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fast_dotenv_rs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e624ecb00bfa47533f8c89fc360d98ae6bd6dfca1cae6866a45f4033ada1f4c
MD5 8b11087d4034cef218d73abe0e494f2e
BLAKE2b-256 6956371372afdd013daef3369a8c420181abc44f24f173968986658ef368abcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1.tar.gz:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_dotenv_rs-0.1.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 382931f250576bb955c00b1932b4a1cc125225ed77045ed6973866beac5df503
MD5 42930b154a45f8b1abb425e6c63b2d55
BLAKE2b-256 9346eaebd49bc375cb296cce7228761bbf70da2c749350931ea5d50d6eacb55a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e94993f6cd2e2d52313001cf0e1fcbc4c2e4f2d8fc2713349cf708552de698c
MD5 1b9ce6809338af2899c9c0002176a0df
BLAKE2b-256 009872b4dec1fcaf4e953696392954c0e890a7f6d414863ad881e8855557b4b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e17f3693bb25c5052d962b62583f51fa174bf69e1b00a53c7c1f6e0f66ee88d
MD5 8a57a1a18903758a8e8931b1d2acd2fe
BLAKE2b-256 15822714105325d1499ba420c1099fd0bc94932db81f6f4b9cb8f6fb944318d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_dotenv_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff8ac51cfeab9da3bcd2ee214e5c7047d3bcfd74c7da164ca1ff6ea078399a72
MD5 64190358c2635067beff9ae1424a7674
BLAKE2b-256 e396102b1f4ea6c7b17c965aa51d968a77ac945b78834c5ad578034740a9f943

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_dotenv_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 05e99fe3eaf49529aac305b9ad673e33104909829d13be7fcd0564e0476f8506
MD5 c256eb9934bc981a91a441435b49187b
BLAKE2b-256 667c7739ca775b6f7f77ad42e5bce0ffd124f996dc2bf63ff3cd028d075f59c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on lowmiaq-gmail/fast-dotenv-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page