Skip to content

python: switch binding library to nanobind #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Doekin
Copy link
Contributor

@Doekin Doekin commented May 8, 2025

This PR migrates the Python bindings for zxingcpp from pybind11 to nanobind.

Key Benefits:

  1. Enhanced IDE Support (Autocompletion & Type Hinting):
    The primary driver for this change is nanobind's straightforward support for generating stub files (.pyi). These stubs enable autocompletion and type hinting in IDEs, significantly improving the development experience when using the zxingcpp library.

    439856664-5b6c6dfc-3e86-450a-b75d-fb6ca92cd863

  2. Smaller Binary Sizes

  3. Faster Compilation Times

Important Structural Change:

  • As a result of this migration and to better accommodate the stub files and nanobind's typical project structure, the zxingcpp Python extension has been refactored from a single-file module (e.g., zxingcpp.pyd or zxingcpp.so) into a Python package (a directory named zxingcpp containing an __init__.py and the compiled extension module).

@axxel
Copy link
Collaborator

axxel commented May 20, 2025

Sorry for not reacting to your PR so far. This is definitively interesting, I just don't have the time right now to properly look into this. But I will at some point in time.

@Doekin
Copy link
Contributor Author

Doekin commented May 21, 2025

No worries, take your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants