Skip to main content

tranche logo

tranche

ConfigParser with layered precedence, provenance, comment-preserving writes, and safe expressions.

The name tranche comes from the French word for slice — a nod to how the library lets you cut cleanly through multiple configuration layers to get a single, effective view of your settings.

Documentation

Full docs: https://xylar.github.io/tranche/

Install

  • From PyPI (no NumPy):
pip install tranche
  • With NumPy extras (to enable safe NumPy expressions):
pip install tranche[numpy]
  • From source (local checkout):
pip install .

Quick start

from tranche import Tranche

config = Tranche()
config.add_from_file("defaults.cfg")
config.add_user_config("user.cfg")

# Simple values
value = config.get("core", "option")

# Expression (literal backend chosen automatically)
points = config.getexpression("plot", "ticks")

# NumPy expression (auto-selects safe backend because allow_numpy=True)
arr = config.getexpression("plot", "bins", allow_numpy=True)

# Or via convenience helper
arr2 = config.getnumpy("plot", "bins")

# Provenance
info = config.explain("plot", "bins")
print(info)

Security notes

  • Expressions default to backend="literal" for safety.
  • The safe backend only allows a small AST subset and a very small set of symbols.
  • NumPy is opt-in via allow_numpy=True and the numpy extra.

Extensibility

You can add your own safe symbols:

import math
config.register_symbol("sqrt", math.sqrt)

Links

License

BSD-3-Clause

Release files for tranche 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tranche 0.6.1
File Size Uploaded
tranche-0.6.1.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tranche 0.6.1
File Interpreter ABI Platform
tranche-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.0 kB

Release files / tranche-0.6.1.tar.gz

Download URL tranche-0.6.1.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b2c7c33e3c4d244b93d704fd417ec4cc08bf762ceda0e3b60111c3bbf9dc46c6
BLAKE2b-256 checksum
How to use checksums
9b5b1368dc8d86a873b8830f86b21685ceca5bfae9821bdf6400739fda6799cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / tranche-0.6.1-py3-none-any.whl

Download URL tranche-0.6.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc299cd938893c064a013bce51e7dffae7a5fc82887d027c44048b17d499398b
BLAKE2b-256 checksum
How to use checksums
d0ac66110b77aa8c203f7e1c317d2a42f15f0120725c285f7d7a2803e6c559e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page