Metadata-Version: 2.4
Name: PyCeler
Version: 0.1.0
Summary: Analyze Python loops and compile numeric workloads with Cython
Requires-Python: >=3.11
License-Expression: MIT
License-File: LICENSE.md
Author: Nucleon Automation
Project-URL: Changelog, https://github.com/nucleonautomation/PyCeler/blob/main/Log.md
Project-URL: Issues, https://github.com/nucleonautomation/PyCeler/issues
Project-URL: Source, https://github.com/nucleonautomation/PyCeler
Requires-Dist: Cython>=3.1
Requires-Dist: setuptools
Description-Content-Type: text/markdown

# PyCeler

PyCeler looks for numeric loops in Python code and tries compiling them with Cython. A loop that clears an array, for example, can split the work across threads because each write is independent. A running sum depends on the previous result and has to keep that order. PyCeler checks which transformations apply, compares their results with Python, and measures whether they save time on the inputs it tried.

## Installation

Install a published release in your Python environment with pip:

```sh
pip install PyCeler
```

PyCeler 0.1.0 provides wheels for standard CPython 3.11 and newer on Windows x64, Linux x86-64, and Linux ARM64. The Linux wheels target glibc distributions. Pip picks the wheel for your interpreter and platform.

You can analyze Python files with the installed package. To generate and benchmark native candidates or compile your own extensions, you’ll also need a C compiler. On Windows, use MSVC Build Tools with the C++ toolchain and Windows SDK. On Linux, use GCC, Python development headers, and the OpenMP runtime.

Install the third-party libraries your code uses in the same environment before optimizing it. Static analysis reads the source without importing it. Validation and timing can execute the code. NumPy is optional for PyCeler itself and is used for array optimizations.

## Try it on a Python file

Point the analyzer at an existing file. Each finding tells you where the loop is and why PyCeler considers it a candidate or skips it.

```python
import PyCeler

source = "my_loops.py"
for loop in PyCeler.Analyze(source):
    print(loop.Function, loop.Line, loop.Reason)
```

To see the generated Cython, call `PyCeler.Convert(source, "output/cython")`. To build an importable extension directly, call `PyCeler.Compile(source, "output/native")`. Both take a file or source directory and write their output separately from your originals. If you already have Cython code, use `PyCeler.Compile("existing.pyx", "output/native", Convert=False)` to compile it directly.

For eligible loops, the selection report shows how Python, serial Cython, and OpenMP performed at different input sizes. A small array can take longer to split across threads than to process on one. At runtime the module uses the implementation selected for the input and falls back to Python when the input falls outside the conditions it checked.

## Build from source

From the root of the GitHub checkout, install the build dependencies and run the build script:

```sh
python -m pip install -r requirements.txt
python -B Compile.py
```

The built package is in `Build/Lib/PyCeler`. To try the analyzer from the checkout, run:

```sh
python -B Compile.py analyze --input Test/Numeric_Loops.py --rank
```

The example contains both the array fill and the running sum. [Example source](https://github.com/nucleonautomation/PyCeler/blob/main/Test/Numeric_Loops.py)

## Project

[GitHub repository](https://github.com/nucleonautomation/PyCeler) · [Changelog](https://github.com/nucleonautomation/PyCeler/blob/main/Log.md) · [Test guide](https://github.com/nucleonautomation/PyCeler/blob/main/Test/README.md) · [MIT license](https://github.com/nucleonautomation/PyCeler/blob/main/LICENSE.md)
