« All posts

Lucen parallelizes Python loops via two comments, bit-identical results

Lucen parallelizes Python for loops via two comments, guaranteeing bit-identical results versus sequential execution. Rust-accelerated, v1.1, Apache-2.0.

Lucen is a source-to-source compiler that turns ordinary Python for loops into parallel code simply by wrapping them in two comments, `# LUCEN START` and `# LUCEN END`. It only parallelizes a loop when static analysis proves the transformation is safe and the workload is large enough to benefit; otherwise the loop runs exactly as written, sequentially.

The project's core guarantee is bit-for-bit identical output between the parallel and sequential versions, including floating-point results and container ordering. Removing the marker comments should change nothing about behavior, which sets Lucen apart from typical parallel libraries that require rewriting logic or accepting nondeterministic results.

Under the hood, CPU-bound work is dispatched to separate processes on standard GIL-based Python builds and to genuine threads on free-threaded Python 3.13/3.14. An optional Rust core accelerates the compiler, while a pure-Python fallback keeps `pip install lucen` dependency-free. At v1.1, the project ships Apache-2.0 licensed with differential and property-based testing, TLA+ specifications, and signed PyPI releases, targeting engineers who want extra cores on CPU-bound loops without adopting multiprocessing, joblib, or manual locking.