Accesses to the internals struct now goes through a with_internals([] { ... }); statement. In the free-threaded build, the internals mutex is locked for the duration of the access.
The registered_instances map has its own locking scheme because it may be frequently accesses by multiple thread. The map is shareded by address and a lock per shard is used to increase concurrency.
Other smaller changes:
Add gil_not_used() tag to indicate that a module supports running with the GIL disabled. See PyUnstable_Module_SetGIL.
Use PyMem_MALLOC for tp_doc in 3.13+
Add dict_getitemstringref to wrap new PyDict_GetItemStringRef API
Suggested changelog entry:
* Support free-threaded CPython (3.13t)
* Add ``py::mod_gil_not_used()`` tag to indicate if a module supports running with the GIL disabled.
Description
Accesses to the
internals
struct now goes through awith_internals([] { ... });
statement. In the free-threaded build, the internals mutex is locked for the duration of the access.The
registered_instances
map has its own locking scheme because it may be frequently accesses by multiple thread. The map is shareded by address and a lock per shard is used to increase concurrency.Other smaller changes:
gil_not_used()
tag to indicate that a module supports running with the GIL disabled. SeePyUnstable_Module_SetGIL
.PyMem_MALLOC
fortp_doc
in 3.13+dict_getitemstringref
to wrap newPyDict_GetItemStringRef
APISuggested changelog entry: