Static AST-based Big-O complexity estimator — no code execution needed
Project description
bigopy 🔍
Static Big-O complexity estimation for Python code via AST analysis. No code execution needed — just point it at your source file.
bigopy statically analyzes Python source files using the Abstract Syntax Tree (AST)
and estimates the Big-O time complexity of every function — without running your code.
$ bigopy analyze bubble_sort.py
============================================================
📂 bubble_sort.py
============================================================
Function: bubble_sort() (line 1)
Complexity: O(n²)
Confidence: [█████████████████░░░] 85%
Reasons:
• doubly-nested loops (depth=2)
Why bigopy is different
| bigopy | Other tools | |
|---|---|---|
| Approach | Static AST analysis | Runtime measurement |
| Runs your code? | ❌ Never | ✅ Must execute |
| Works on broken code? | ✅ Yes | ❌ No |
| Dependencies | Zero | numpy, etc. |
| Graph algorithms | ✅ O(V+E), O((V+E)logV) | ❌ No |
| Safe for CI/CD | ✅ Yes | ⚠️ Maybe |
Installation
pip install bigopy
Quick Start
CLI
bigopy analyze my_module.py
bigopy analyze my_module.py --verbose
bigopy analyze src/ --format json
bigopy analyze my_module.py --only bubble_sort
Python API
from bigopy import analyze_file, analyze_source
# From a file
result = analyze_file("my_module.py")
for func in result.functions:
print(f"{func.name}: {func.complexity.label} ({func.confidence:.0%})")
# From a string
source = """
def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
"""
result = analyze_source(source)
print(result.functions[0].complexity.label) # O(n²)
Detected Complexity Classes
| Class | Pattern Detected |
|---|---|
O(1) |
No loops, no recursion |
O(log n) |
Halving/doubling while loops |
O(n) |
Single loop over input |
O(n log n) |
Divide-and-conquer, sorted() |
O(n²) |
Doubly-nested loops |
O(n³) |
Triple loops, range(i*i) |
O(2^n) |
Branching recursion |
O(V+E) |
DFS, BFS graph traversal |
O((V+E) log V) |
Dijkstra, Prim |
Project Structure
bigopy/
├── bigopy/
│ ├── analyzers/ # estimation engine
│ ├── detectors/ # loop, recursion, graph, builtin
│ └── reporters/ # terminal, json output
├── tests/ # test suite
├── examples/ # demo algorithms
└── README.md
License
MIT © 2024 Zul-Qarnain
Project details
Release history Release notifications | RSS feed
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 bigopy-0.1.0.tar.gz.
File metadata
- Download URL: bigopy-0.1.0.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f30f2c27f0f9aeb589bc2a8a5b621fcbeecf3c422f5a2cec68b52cafe168774c
|
|
| MD5 |
c1a24499a0edb5a59feba705eb8867b7
|
|
| BLAKE2b-256 |
90e5dbdc331463276f44abc5cc972ee9b96788c5e287d9954147a1069bfef99a
|
File details
Details for the file bigopy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bigopy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b010f1c4857b882bc56fe8a7586f8febb9557b8af3283c9784a86d4955417723
|
|
| MD5 |
454041d708552b7a10f01a6536f45be1
|
|
| BLAKE2b-256 |
5c1cd6e3582514a75e0bf04bb6d3102b6b15a361f84c00656a1b8ce3524c868c
|