Skip to main content

Rust/PyO3 accelerator for pyhocon: a native, iso-functional HOCON parser with transparent fallback to pyhocon.

Project description

pulse-pyhocon

Rust/PyO3 accelerator for pyhocon — a native, iso-functional HOCON parser, with transparent fallback to pyhocon. A Pulse by Astek project.

pyhocon is built on pyparsing; its parsing is dominated by interpreted-Python machinery (~99% of the time, ~1% in C regex). pulse-pyhocon reimplements the hot path in Rust and delegates the rest to pyhocon — keeping correctness, gaining an order of magnitude.

import pulse_pyhocon
config = pulse_pyhocon.parse(text)   # a real pyhocon.ConfigTree (full API), parsed in Rust
config.get_int("server.port")        # get_string/int/float/bool/list/config, dotted access, defaults…
config.get("db.host", "localhost")
config.with_fallback(pulse_pyhocon.parse(defaults))

parse / parse_string / parse_file return a real pyhocon.ConfigTree, so the whole pyhocon API works (typed getters, dotted access, with_fallback, as_plain_ordered_dict, HOCONConverter.to_hocon/json/yaml/properties). ConfigFactory, ConfigTree, HOCONConverter, from_dict, parse_URL are re-exported for a drop-in import. The Rust core parses quickly, then the tree is built via ConfigFactory.from_dict (getters/converters stay pyhocon's → iso, no reimplementation off the hot path).

Why

  • ~200–350× faster than pyhocon for parse(...) → ConfigTree (the bottleneck is interpreted Python, not a C extension — a textbook case for Rust). Measured with a drift-immune A/B on realistic configs. (Raw parsing alone reaches ~1000–5000×; building the full ConfigTree adds a modest cost, kept here for full API compatibility.)
  • Iso-functional: every output is validated against pyhocon by a typed differential oracle (result and exception type), over a large corpus + full-Unicode adversarial fuzzing.
  • Always correct: anything the fast path does not cover is delegated transparently to pyhocon (internal NotImplementedError → fallback). The drop-in never "breaks" on HOCON that pyhocon accepts.

Fast-path coverage (Rust)

Objects, arrays, scalars (int — including > 64 bits →, float, case-insensitive bool/null), dotted keys, deep merge, comments #///, substitutions ${path}/${?path} (type preserved, concatenation, forward/backward refs, sub→sub, optional omitted, env fallback), file includes, object (merge) and array concatenation, and self-reference (path = ${path}":/usr/bin", a = ${a} [2], object self-merge…). pyhocon exception parity (ConfigSubstitutionException, ConfigWrongTypeException, FileNotFoundError).

Delegated to the pyhocon fallback (correct, no speedup): += (pyhocon-specific behavior), quoted keys with special characters, empty values, include url(...)/classpath(...), a bare true/false/null keyword inside an unquoted multi-token run, extreme floats in a string concat, and the self-reference corner cases the native core does not handle (previous value not yet resolved, absolute-path nested self-ref, path navigation through a substitution ${x.host}). The native core only attempts the happy path; as soon as it cannot resolve something, it delegates to pyhocon (the oracle), which resolves the idiom or raises the right exception. Guarantee: never a divergence, even on these corner cases.

Installation

pip install pulse-pyhocon      # also pulls pyhocon (used for the fallback and the ConfigTree)

Prebuilt wheels are published for Linux (manylinux/musllinux x86_64 & aarch64), macOS (Apple Silicon) and Windows. On other platforms (e.g. macOS Intel) the install builds the Rust core from the sdist (a Rust toolchain is required); the module remains usable via the pure-Python fallback if the native extension is unavailable.

Status

Alpha. API: parse/parse_string/parse_filepyhocon.ConfigTree; parse_URL/from_dict re-exported. pulse_pyhocon.BACKEND is "rust" or "python". Roadmap (perf — iso is already guaranteed via the fallback): resolve, natively (instead of via fallback), path navigation through a substitution; native include url/classpath; a macOS Intel (universal2) wheel.

License & credits

Apache-2.0 (aligned with pyhocon). pulse-pyhocon relies on pyhocon (chimpler/pyhocon, Apache-2.0) as its iso-functionality reference and as the fallback. Thanks to its authors and contributors.

Project details


Download files

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

Source Distribution

pulse_pyhocon-0.2.1.tar.gz (26.0 kB view details)

Uploaded Source

Built Distributions

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

pulse_pyhocon-0.2.1-cp311-abi3-win_amd64.whl (160.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.4 kB view details)

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

pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (262.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

pulse_pyhocon-0.2.1-cp311-abi3-macosx_11_0_arm64.whl (248.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file pulse_pyhocon-0.2.1.tar.gz.

File metadata

  • Download URL: pulse_pyhocon-0.2.1.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pulse_pyhocon-0.2.1.tar.gz
Algorithm Hash digest
SHA256 45307ff0a4faa7cf80f580a50cd9523fdd7f2167f6d198738c21f23c861eb755
MD5 f5db6541b2ba0a8e0becadf3a731a8ad
BLAKE2b-256 f651b0672828d7c4b11b7c861e2a30462e3991d93271811e05f7ee290aec4b1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_pyhocon-0.2.1.tar.gz:

Publisher: release.yml on AstekGroup/pulse-pyhocon

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

File details

Details for the file pulse_pyhocon-0.2.1-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pulse_pyhocon-0.2.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6ee7972583ee4dc2cda21318a65efb6d5e8b608b6667eea65e8492def212188f
MD5 af90610ef9b998f9f39d594706d443cc
BLAKE2b-256 48ee392eee4d9b261c4cdd751ddc56731c26f2f53b86596f1bcef7485fb98e2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_pyhocon-0.2.1-cp311-abi3-win_amd64.whl:

Publisher: release.yml on AstekGroup/pulse-pyhocon

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

File details

Details for the file pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f56dc8b03fdae46b476c4946c2d5519ef2896e56853b1e7f0d3437520a511843
MD5 5890c28f046def7373ed7b313a338854
BLAKE2b-256 425f85496645fd421d3bc2319daf8d9781fe35192ca7e7b84205251d7a77d161

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on AstekGroup/pulse-pyhocon

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

File details

Details for the file pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1be8d58c8876788e0665071e3d369df6f12e77118aae0318e5429c6f39dfc7d5
MD5 fa8c9d5e6f3409ed2aa314b81bd0c6b9
BLAKE2b-256 7b8966c462e07d3558538d0668644870db04b67011eee58a4f83325734cf6244

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_pyhocon-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on AstekGroup/pulse-pyhocon

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

File details

Details for the file pulse_pyhocon-0.2.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulse_pyhocon-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce39497960679c773329d6ef135a50d0eb78fbd638f9fb5dfc1930475e7e01f0
MD5 105ca3df40043f6072dc9fdf0446a7a2
BLAKE2b-256 b50d0eb425175654aa0ece7be26f917f3ea934c74ccc26d58cd4c0a73ec5d986

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_pyhocon-0.2.1-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on AstekGroup/pulse-pyhocon

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 Pingdom Monitoring Sentry Error logging StatusPage Status page