Skip to main content

fast-dotenv-rs

CI 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

This is a public pre-release source repository. It has not yet been published to PyPI and no GitHub Release has been created.

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

There is no PyPI package yet. Build from source:

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
python -m pip install "click>=5" # optional, required for the CLI
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.0.tar.gz (781.6 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.0-cp310-abi3-win_amd64.whl (135.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

fast_dotenv_rs-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.7 kB view details)

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

fast_dotenv_rs-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (223.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fast_dotenv_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (206.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fast_dotenv_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (213.9 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: fast_dotenv_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 781.6 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.0.tar.gz
Algorithm Hash digest
SHA256 8963329b8db0b635062efbe74f2f2ef8f7c7b6e7bb0bff539825bb23aa13eb08
MD5 f30d535b2fe6d3e079f50eb23765558a
BLAKE2b-256 12b7a19287dd09487332e951e72b3194fdf1c8c7098bf3675eb723e179edfb84

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0.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.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 97faff0dd93c75e9928cec92589c08c36a751ebd1507a90f5a72d1973be279a5
MD5 8c6a1e22f749daad3b25c071e5e0fe96
BLAKE2b-256 4cd6c2d49c1357f3c000be5400e63a332c04525681d02214e36f0ba2b6590086

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0-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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 925c1c448a2132de18d3984ee274e1e0c78d6a5469e316013502fda393435fe9
MD5 970c86520851922d5eef5b1bfd116a6a
BLAKE2b-256 a286f46f1416689cb23aacb1afdaf33a391f14e14d4219c449ac1171b0172bc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0-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.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 93013b86c97e638d813543fa55fb68248ecdd43d7a127a64462bd9a9fbb4d8f4
MD5 0bf6f17a94645ed75c4fd1e99998e3de
BLAKE2b-256 d298c22f8fb5b8a8025bbbc2b9dbc8dcf4f378e5e9b4b4ec5b2f42d9b5d86e11

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0-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.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71acdb1ed890dcec30d8a26b7b452eddbbb6a0fb68d1adeb72575a1159c3dc07
MD5 25551d8d062f033847a20a38db3ffef9
BLAKE2b-256 fa731ee3668c03ec46037d9eb191c061844276bb3619926c7012cdc3de708c14

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0-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.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fast_dotenv_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be2f4bc624a8a49f80e4715345e9ec12dc92d0afe4e96019a610a45e6882df81
MD5 7a6e4ed1f2b6fa9d795997ce23e647bc
BLAKE2b-256 07d83522d802e84900e2ea928f8906cfd4800781402bc49c0499ed5fe2669f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_dotenv_rs-0.1.0-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