This project explores performance optimization techniques in Python using a custom-built chess engine as a benchmarking tool. The goal is to evaluate how far Python-based applications can be pushed using various modern optimization tools, including Cython, Numba, Nuitka, and even a full C++ rewrite wrapped with Cython.
See the techincal report for more information about the project.
.
├── Cpp_cython/ # Chess engine rewritten in C++ with a Cython wrapper
├── default/ # Pure Python baseline implementation
├── onlyCython/ # Python engine with Cython-based optimizations
├── nuitka/ # Nuitka-compiled version of the Python engine
├── numbaEngine/ # Python engine with Numba JIT optimizations
├── install.sh # Installation script (requires pyenv)
├── run.sh # Benchmark runner script
Before getting started, ensure you have the following installed:
pyenv— for managing Python versionsbash(for running the scripts)- C/C++ compiler (e.g.,
gcc,clang) for Cython/Nuitka/C++ builds
Run the installation script to install all required Python versions and dependencies:
./install.shThis script uses pyenv to set up the correct Python environments and installs all needed libraries (e.g., numpy, cython, numba, etc.).
To execute all engine versions and run the benchmark suite:
./run.shThis will benchmark each implementation and output evaluation speed (nodes/sec) and playing strength comparisons.
| Engine | Description |
|---|---|
default |
Baseline engine using pure Python 3.10 |
onlyCython |
Python engine statically compiled via Cython |
numbaEngine |
Numba-accelerated version of the Python engine |
nuitka |
Ahead-of-time compiled version via Nuitka |
Cpp_cython |
Full C++ rewrite exposed to Python using Cython |
This project is for educational and benchmarking purposes. Feel free to fork or extend it.
Inspired by https://github.com/healeycodes/andoma