Metadata-Version: 2.4
Name: pydeltacode
Version: 0.1.3
Summary: Optimise your code for runtime performance, loc or peak memory on demand inside your script and compare LLM suggestions against your code. Solutions are tested end-to-end against the function calls executed and results are stored locally for manual verification. This package is designed to retain benefits of AI refactoring but keep an engineer friendly workflow.
Project-URL: Homepage, https://www.deltacode.org
Project-URL: Documentation, https://www.deltacode.org
Project-URL: Repository, https://github.com/MountainClimber2000/pydeltacode
Author-email: Kyle Winkler <kylewinkler@deltacode.com.au>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: anthropic>=0.80
Requires-Dist: fpdf2>=2.8
Requires-Dist: openai>=1.0
Requires-Dist: pyyaml>=6.0
Description-Content-Type: text/markdown

# pydeltacode

Optimise your code for runtime performance, loc or peak memory on demand inside
your script and compare LLM suggestions against your code. Solutions are tested
end-to-end against the function calls executed and results are stored locally
for manual verification.

**📖 Full documentation: [www.deltacode.org](https://www.deltacode.org)**


## Install

```
pip install pydeltacode
```

For development (editable install from a checkout of this repo):

```
pip install -e .
```

## Usage

```python
from pydeltacode import refactor, llm

# One of eight providers: openai, anthropic, gemini, xai, deepseek,
# mistral, kimi, openrouter. ${VAR} is resolved from the environment
# at runtime, so the key never lives in your source.
llm.set_credentials("openai", "${PROVIDER_API_KEY}")

optimise = refactor(objective="speed")


@optimise.track
def sum_of_squares(values):
    squares = []
    for v in values:
        squares.append(v * v)
    total = 0
    for s in squares:
        total = total + s
    return total


if __name__ == "__main__":
    sum_of_squares(list(range(5_000)))     # record a real call
    result = optimise.optimise(            # refactor, verify, keep the best
        sum_of_squares, tries=5, use_captured_inputs=True
    )
    print(result["winner_version"], result["report_path"])
```

`optimise()` sends the tracked function to your provider, runs each suggestion
against the calls you actually recorded, and only keeps a candidate whose
outputs match the original *and* which improves the objective. The winner is
written back into your source file; every attempt, the code sent and received,
and a PDF report are saved locally.

Tracked/refactored data is written to `.pydeltacode/<hash>/` (gitignored) in
the current working directory. Save location can also be changed.  
