Adaptive Code Flow Optimizer (ACFO)
The Adaptive Code Flow Optimizer (ACFO) is a Python framework that dynamically optimizes the execution order of function calls, prioritizing high-cost operations while respecting dependencies. By leveraging runtime profiling and a Control Flow Graph (CFG), ACFO enhances performance in applications like data pipelines, web servers, and IoT devices without requiring code modifications.
Key Features
- Dynamic Optimization: Reorders function calls based on a heuristic ( h(v) = \text{frequency} \cdot \text{cost} ).
- Dependency-Aware: Ensures correct execution order using a CFG parsed with Python's
astmodule. - Transparent: Integrates seamlessly with existing Python code.
- Open-Source: Licensed under MIT, welcoming contributions.
Why Use ACFO?
- Performance Gains: Reduces execution time by prioritizing costly functions.
- Ease of Use: No need to rewrite code; ACFO profiles and optimizes automatically.
- Versatility: Applicable to scientific computing, web development, and embedded systems.
Installation
- Clone the repository:
git clone https://github.com/your-username/acfo.git cd acfo
- Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies (none required currently):
pip install -r requirements.txt
- Install ACFO as a package (optional):
pip install .
Quick Start
Optimize a simple program with two functions:
from acfo import ACFO
def a():
time.sleep(0.1) # Simulates a costly task
return "A"
def b():
time.sleep(0.05) # Simulates a lightweight task
return "B"
acfo = ACFO()
acfo.parse_code("""
def a():
b()
def b():
pass
""")
functions = {"a": a, "b": b}
calls = []
for _ in range(10):
acfo.monitor_execution("a", a)
acfo.monitor_execution("b", b)
calls.append("a")
calls.append("b")
print("Initial Calls:", calls)
calls = []
acfo.execute_optimized(functions, calls, 20)
print("Optimized Calls:", calls)
Expected Output:
Initial Calls: ['a', 'b', 'a', 'b', ..., 'a', 'b']
Optimized Calls: ['a', 'b', 'a', 'b', ..., 'a', 'b']
Use Cases
- Data Pipelines: Optimize workflows like
read_data -> transform_data -> write_data(seeexamples/data_pipeline.py). - Web Servers: Reduce latency in Flask/Django by reordering middleware or route handlers.
- IoT Devices: Minimize execution time in resource-constrained environments.
Project Structure
Adaptive-Code-Flow-Optimizer/
├── acfo/ # Core module
│ ├── __init__.py
│ ├── acfo.py
├── examples/ # Example scripts
│ ├── simple_dependency.py
│ ├── data_pipeline.py
├── tests/ # Unit tests
│ ├── test_acfo.py
├── docs/ # Detailed documentation
│ ├── architecture.md
│ ├── contributing.md
├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
├── setup.py
Contributing
We welcome contributions! Please read contributing.md for guidelines on reporting issues, submitting pull requests, and coding standards.
Documentation
- Architecture: Technical details and mathematical foundations.
- Contributing: How to contribute to ACFO.
License
Contact
- GitHub: dev-queiroz
- Email: your.email@example.com
- Issues: github.com/dev-queiroz/acfo/issues
ACFO: Optimize your Python code dynamically, effortlessly, and intelligently.
Metadata
Release files for acfo 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| acfo-1.0.0.tar.gz | 9.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| acfo-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / acfo-1.0.0.tar.gz
| Download URL | acfo-1.0.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0744081cebd0c63fd545bc9be8d82f0eead2457c36ed681eeebd3f5c7cd26acc
|
|
BLAKE2b-256 checksum How to use checksums |
bee7f98fafa9b6854c79dac020f006397b7a163d5f8930ac6d15aac093dc4ba7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / acfo-1.0.0-py3-none-any.whl
| Download URL | acfo-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed9e6d3190a1318f6413c9b4610d161cc923c039eea25e50494eb7f5fffa4225
|
|
BLAKE2b-256 checksum How to use checksums |
41930de15b4134171fbfd16ec0c68d40b58a1ac2ddf52275d00f9213c3a240a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for acfo 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.