Metadata-Version: 2.3
Name: bifurcate
Version: 1.0.3
Summary: Emergent parallelism and execution branching from inside your functions
Keywords: parallelism,branching,concurrency,decorator,execution
Author: Wannes Vantorre
Author-email: Wannes Vantorre <vantorrewannes@gmail.com>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.14
Project-URL: Homepage, https://codeberg.org/ProductionCode/bifurcate
Project-URL: Repository, https://codeberg.org/ProductionCode/bifurcate
Project-URL: Issues, https://codeberg.org/ProductionCode/bifurcate/issues
Description-Content-Type: text/markdown

# 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

```python
import bifurcate

@bifurcate.collect
def calculate_pricing(user_id):
    # 1. Standard execution starts normally
    base_price = database.get_price(user_id)

    # BRANCH POINT:
    # The system transparently branches the execution universe here.
    # The function will conceptually branch, returning a different
    # value to 'discount' for each path.
    discount = bifurcate.branch([0.0, 0.10, 0.20])

    # 2. This logic is evaluated cleanly for each distinct branch
    final_price = base_price * (1 - discount)

    print(f"Calculated: {final_price}")
    return final_price

# The decorator catches the parallel universes and aggregates the results
results = calculate_pricing("user_123")
# Output: [100.0, 90.0, 80.0]
```

## Features

- **In-line Branching:** No more `for` loops 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.

## Installation

```bash
uv add bifurcate
# or
pip install bifurcate
```
