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
Install
pip install pydeltacode
For development (editable install from a checkout of this repo):
pip install -e .
Usage
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydeltacode-0.1.3.tar.gz.
File metadata
- Download URL: pydeltacode-0.1.3.tar.gz
- Upload date:
- Size: 56.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1b83b53e76d466b608b3d71c7dc0d9b8096228a00441ee694a636907a4cd12e
|
|
| MD5 |
8db249ef08dc1962b13a272c5ef8f9a2
|
|
| BLAKE2b-256 |
fdc53f30fe8a977363a95dd28713f2c206d11fdfae5e488c0ce3d24ca9a7b490
|
File details
Details for the file pydeltacode-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pydeltacode-0.1.3-py3-none-any.whl
- Upload date:
- Size: 50.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d3df8c7919867081805b4d97338ef407a042825416c98ddf844dd5f7534f70f
|
|
| MD5 |
f6172676eb1778b85b775dd6959f5690
|
|
| BLAKE2b-256 |
fe29d99710ee4fdd292436886a49a63419cf831a0cd830606d74fb6fc0b939b0
|