Coding super-intelligence to find the most optimized Python code. Use it to optimize existing codebases or new Pull requests as a GitHub Action or a VS Code Extension.
Find a file
2025-04-01 23:18:42 +00:00
.github/workflows Make codeflash github actions cooler? 2025-03-24 15:11:56 -07:00
code_to_optimize Merge branch 'main' into tracer_tracker 2025-03-13 00:34:10 +00:00
codeflash Merge branch 'main' into pytest-discovery-optimization 2025-04-01 18:59:18 -04:00
docs minor 2025-03-31 15:44:39 -07:00
tests prevent nested classes/ functions from showing up in code context . helper_functions 2025-04-01 15:26:40 -07:00
.gitignore Use Pathlib instead, added .DS_Store to .gitignore 2025-02-14 23:19:14 +08:00
codeflash.code-workspace pass the right directory as arg 2025-03-03 15:17:40 -08:00
mypy_allowlist.txt mypy fixes 2024-12-26 14:46:26 -08:00
pyproject.toml check for GH App 2025-03-31 19:39:44 -05:00
README.md improvements to the readme 2025-03-25 10:47:42 -07:00

Codeflash-banner

GitHub commit activity PyPI Downloads PyPI Downloads

Codeflash is a general purpose optimizer for Python that automatically improves the performance of your Python code while maintaining its correctness.

How Codeflash works:

  1. LLMs generate multiple optimization candidates for your code
  2. Codeflash tests the optimization candidates for correctness
  3. 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

  1. Run the following command at the root directory of your project where the pyproject.toml file is located

    codeflash init
    

    This 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.
  2. Optimize a file:

    codeflash --file <path/to/file.py>
    
  3. 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.