A micro-benchmarking tool for comparing integer parity checks in Python — including modulo division, bitwise AND, and their compiled C equivalents via ctypes, with support for both single-value and batch-mode testing.
py_bitmod is a minimal Python 3 project for benchmarking the runtime performance of various parity-checking methods:
- Modulo method
- Bitwise method
- C bitwise method — compiled C function via
ctypes - Batch bitwise method — Python loop over randomized input array
- Batch C bitwise method — compiled C function via
ctypes, optimized for batch processing
The CLI measures execution time using Python’s time.perf_counter().
Create a virtual environment and install the package:
python3 -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install .make # build shared and static libraries
make install # install libbitmod.so for CLI usage
make test # test run with default input
make rebuild # clean and rebuild all artifacts
make clean # remove build artifacts and installed library# Show help message
py-bitmod -h
# Run with optional test value and batch size
py-bitmod [test_value] [batch_size]# Show help message
python3 py_bitmod.py -h
# Run with optional test value and batch size
python3 py_bitmod.py [test_value] [batch_size]Building the C extension requires:
make— to run build commandsgcc— to compile the C source code