Skip to content

fr: Implement core logic in Zig #3

@hssyoo

Description

@hssyoo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions