bifurcate
Emergent parallelism and execution branching from inside your functions.
Standard patterns force you to extract your logic and wrap it in for loops or complex task graphs just to run variations of a pipeline. bifurcate lets you branch the execution graph dynamically from inside the function itself.
Write your logic sequentially, as if it only runs once. Let the system magically map the permutations.
Usage
import bifurcate
@bifurcate.collect
def calculate_pricing(user_id):
base_price = database.get_price(user_id)
# BRANCH POINT:
# The system transparently forks the execution universe here.
discount = bifurcate.branch([0.0, 0.10, 0.20])
final_price = base_price * (1 - discount)
# You own the traceability. Return a dict to map paths to results.
return {"discount": discount, "price": final_price}
# The decorator automatically aggregates the permutations
results = calculate_pricing("user_123")
# Output:[{'discount': 0.0, 'price': 100}, {'discount': 0.1, 'price': 90}, ...]
Features
- In-line Branching: No more
forloops polluting your caller logic. Keep your domain functions completely isolated and focused on single-item math. - Zero-Boilerplate Permutations: Perfect for A/B testing, ML hyperparameter sweeps, or fallback strategies.
- The List Monad for Python: Achieves mathematically pure map/flatMap operations using standard, highly-readable imperative Python syntax.
Core Mechanics
- Bytecode Identity: The system doesn't track sequence order. It uses Python's bytecode instruction pointer (
f_lasti) to identify branches. This means you can safely placebranch()inside unpredictableifstatements or unorderedset()iterations. The execution topology can be completely dynamic. - Primitive Composition: Because
bifurcatesimply re-evaluates the function using native mechanics, it composes flawlessly with pure caching tools. Heavy setup steps before the fork can be memoized seamlessly without DAG configuration.
Installation
uv add bifurcate
# or
pip install bifurcate
Metadata
Release files for bifurcate 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bifurcate-2.0.0.tar.gz | 2.7 kB | Without provenance | Details for bifurcate-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bifurcate-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for bifurcate-2.0.0-py3-none-any.whl |
Total release size: 6.3 kB
Release files / bifurcate-2.0.0.tar.gz
| Download URL | bifurcate-2.0.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b5183b759b8d1a1ca6ef7890e6b08bd9aa47ce40af1e859a181a54130807f1a
|
|
BLAKE2b-256 checksum How to use checksums |
f91d5f278228f75be3eb66d0c51ea91855347ebdbeabe754a31ea28c1d2742ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bifurcate-2.0.0-py3-none-any.whl
| Download URL | bifurcate-2.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
feca4edcf8efad79a6e9eb04f6ee969b096c4d9ba8d017de8b4e06687c23fde2
|
|
BLAKE2b-256 checksum How to use checksums |
1cf8f5962015c6d5db0fb1174844b3142de4f1d93fb31c334fec4f0c0ed2cf2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for bifurcate 2.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.