| .github/workflows | ||
| code_to_optimize | ||
| codeflash | ||
| docs | ||
| tests | ||
| .gitignore | ||
| codeflash.code-workspace | ||
| mypy_allowlist.txt | ||
| pyproject.toml | ||
| README.md | ||
Codeflash is a general purpose optimizer for Python that automatically improves the performance of your Python code while maintaining its correctness.
How Codeflash works:
- LLMs generate multiple optimization candidates for your code
- Codeflash tests the optimization candidates for correctness
- Codeflash benchmarks the optimization candidates for performance
Should the optimization be valid and faster than the original code, Codeflash will create a pull request with the optimized code. You can now review and merge the code to make your codebase faster!
Ways to use Codeflash:
- Optimize an entire codebase by running
codeflash --all - Automatically optimize all future code written by installing Codeflash as a GitHub action. Codeflash will try to optimize your new code before you merge it into the codebase.
- Optimize a Python workflow end-to-end by tracing the workflow.
Codeflash is used by top engineering teams at Pydantic, Langflow, Albumentations and many others to ship performant, expert level code.
Codeflash is great at optimizing AI Agents, Computer Vision algorithms, numerical code, backend code or anything else you might write with Python.
Installation
To install Codeflash, run:
pip install codeflash
Add codeflash as a development time dependency if you are using package managers like uv or poetry.
Quick Start
-
Run the following command at the root directory of your project where the pyproject.toml file is located
codeflash initThis will set up basic configurations for your project, eg:
- Input a Codeflash API key (for access to LLMs)
- Enable a GitHub app to open Pull Requests on the repo
- [Optional] Setup a GitHub actions which will optimize all your future code.
-
Optimize a file:
codeflash --file <path/to/file.py> -
Optimize your entire codebase: (This will run for a while and open PRs as it finds optimizations)
codeflash --all
Documentation
For detailed installation and usage instructions, visit our documentation at docs.codeflash.ai
Demo
- Optimizing the performance of new code for a Pull Request through GitHub Actions. This lets you ship code quickly while ensuring it remains performant.
https://github.com/user-attachments/assets/38f44f4e-be1c-4f84-8db9-63d5ee3e61e5
Support
Join our community for support and discussions. If you have any questions, feel free to reach out to us using one of the following methods:
License
Codeflash is licensed under the BSL-1.1 License. See the LICENSE file for details.
