Skip to content
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

refactor: use PYBIND11_MODULE #11

Merged

Conversation

henryiii
Copy link

Trying out PYBIND11_MODULE variable args.

henryiii added 2 commits May 30, 2024 10:33
Signed-off-by: Henry Schreiner <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
@colesbury
Copy link
Owner

@henryiii, I think you can use ## to eat the trailing comma if __VA_ARGS__ is empty:

pybind11::module_::create_extension_module(name, doc, def, ##__VA_ARGS__);

It looks like pybind11 uses this in one place already:

https://github.com/pybind/pybind11/blob/1a0ff405498b6aac4b57cf0d95670010e5e37973/include/pybind11/cast.h#L869

@henryiii
Copy link
Author

henryiii commented May 30, 2024

Ah, was going to say it's non-standard, but if we already use it, maybe it's close enough to standard, I could try it.

@colesbury colesbury merged commit 1831bde into colesbury:pep703-support May 31, 2024
80 checks passed
colesbury added a commit that referenced this pull request Jun 26, 2024
* Support free-threaded CPython (PEP 703)

Some additional locking is added in the free-threaded build when
`Py_GIL_DISABLED` is defined:

- Most accesses to internals are protected by a single mutex
- The registered_instances uses a striped lock to improve concurrency

Pybind11 modules can indicate support for running with the GIL disabled
by calling `set_gil_not_used()`.

* refactor: use PYBIND11_MODULE (#11)

Signed-off-by: Henry Schreiner <[email protected]>

* Address code review

* Suppress MSVC warning

* Changes from review

* style: pre-commit fixes

* `py::mod_gil_not_used()` suggestion.

* Update include/pybind11/pybind11.h

---------

Signed-off-by: Henry Schreiner <[email protected]>
Co-authored-by: Henry Schreiner <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants