mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-24 23:07:00 +00:00
fix: support free-threaded CPython with GIL disabled (#5148)
* 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 <henryschreineriii@gmail.com> * 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 <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
This commit is contained in:
@@ -1553,7 +1553,9 @@ PYBIND11_NOINLINE void register_structured_dtype(any_container<field_descriptor>
|
||||
|
||||
auto tindex = std::type_index(tinfo);
|
||||
numpy_internals.registered_dtypes[tindex] = {dtype_ptr, std::move(format_str)};
|
||||
get_internals().direct_conversions[tindex].push_back(direct_converter);
|
||||
with_internals([tindex, &direct_converter](internals &internals) {
|
||||
internals.direct_conversions[tindex].push_back(direct_converter);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename T, typename SFINAE>
|
||||
|
||||
Reference in New Issue
Block a user