Metadata-Version: 2.4
Name: ocalc
Version: 0.1.0
Summary: Measure a Python function and comment its time and space complexity.
License-Expression: MIT
Project-URL: Homepage, https://github.com/Anuj-Attri/ocalc
Project-URL: Documentation, https://anuj-attri.github.io/ocalc/
Project-URL: Repository, https://github.com/Anuj-Attri/ocalc
Project-URL: Issues, https://github.com/Anuj-Attri/ocalc/issues
Keywords: complexity,benchmark,big-o,profiling
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2; extra == "mcp"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx<8,>=7.2; extra == "docs"
Requires-Dist: pytorch-sphinx-theme2==0.4.13; extra == "docs"
Dynamic: license-file

# ocalc

`ocalc` measures a Python function and writes a one-line estimate of its time and space complexity.

```python
# ocalc: Time: O(n); Space: O(1); Worst: 0.42 s at n=100000; Median: 0.31 s; Confidence: high; Protocol: min_n=100,max_n=100000,measures=8,budget=5,repeats=5
def two_sum(nums, target):
    ...
```

## Install

```bash
pip install ocalc
pip install "ocalc[mcp]"
```

## Use

```bash
ocalc measure FILE -f two_sum --sample "[1, 2, 3], 9"
ocalc annotate FILE -f two_sum --sample "[1, 2, 3], 9"
```

![ocalc annotate writes the measured comment above the function](https://raw.githubusercontent.com/Anuj-Attri/ocalc/main/docs/images/annotate.png)

Try a snippet on the [demo](https://anuj-attri.github.io/ocalc/demo.html). The page reports the worst case in the file. The guide and API reference are at [anuj-attri.github.io/ocalc](https://anuj-attri.github.io/ocalc/).

## Development

```bash
pip install -e ".[dev,docs]"
pytest
sphinx-build -b html docs docs/_build/html
```
