Catalog PyPI
PACKAGE EXPLORERView in registry

acfo

PyPI

Adaptive Code Flow Optimizer for Python

code-flowdependenciesoptimizationpython
Versions collected1
Direct dependencies0From release 1.0.0
Last observed20 Oct, 18:11 UTC

README

Version 1.0.0 documentation

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 ast module.
  • 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

  1. Clone the repository:
    git clone https://github.com/your-username/acfo.git
    cd acfo
    
  2. Create a virtual environment:
    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install dependencies (none required currently):
    pip install -r requirements.txt
    
  4. 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 (see examples/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

License

MIT License

Contact


ACFO: Optimize your Python code dynamically, effortlessly, and intelligently.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.022 Jun 20250

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
dev-queiroz/acfo

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:11 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:ba00559f71c21988ab5155d3342d86a18e0aaa3374f51a64fcc244802fc62760