I have a local branch that implements the core bofa logic in Zig. It uses the ziglang package (PyPI source) as a build dependency to compile the Zig code into a native Python extension. The main benefit with this approach is that the bofa utility runs ahead-of-time compiled native code instead of interpreting Python bytecode at runtime.
Disclaimer: I used an LLM to prototype and benchmark.
Initial findings show that the Zig implementation results in ~12% faster wall clock time:
| Metric |
v0.0.2 (Python) |
v0.0.3 (Zig) |
Delta |
| wall |
0.137s |
0.121s |
-12% |
| user |
0.050s |
0.043s |
-14% |
| sys |
0.025s |
0.021s |
-16% |
This gain doesn't come for free. This introduces build complexity to what's currently a pure Python package. We need a new build dependency on ziglang and would need to manage platform-specific distributions (though Zig makes cross-platform compilation super easy, FWIW). Zig also hasn't released a stable major version yet so there may be future maintenance pain involved.
Thoughts? May not make sense now, but in the future as this project matures we may want to find optimizations outside of pure Python.
I have a local branch that implements the core
bofalogic in Zig. It uses theziglangpackage (PyPI source) as a build dependency to compile the Zig code into a native Python extension. The main benefit with this approach is that thebofautility runs ahead-of-time compiled native code instead of interpreting Python bytecode at runtime.Disclaimer: I used an LLM to prototype and benchmark.
Initial findings show that the Zig implementation results in ~12% faster wall clock time:
This gain doesn't come for free. This introduces build complexity to what's currently a pure Python package. We need a new build dependency on
ziglangand would need to manage platform-specific distributions (though Zig makes cross-platform compilation super easy, FWIW). Zig also hasn't released a stable major version yet so there may be future maintenance pain involved.Thoughts? May not make sense now, but in the future as this project matures we may want to find optimizations outside of pure Python.