Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,13 @@ is resumed, and its locks reacquired. This means the critical section API
provides weaker guarantees than traditional locks -- they are useful because
their behavior is similar to the :term:`GIL`.

Critical sections are appropriate for protecting custom types defined by your
C-API extensions. They should generally not be used with built-in types like
:c:struct:`PyDictObject` or :c:struct:`PyListObject` because their public APIs
already use critical sections internally, with the :ref:`notable
exception<PyDict_Next>` of :c:func:`PyDict_Next`, which requires external
locking.

The functions and structs used by the macros are exposed for cases
where C macros are not available. They should only be used as in the
given macro expansions. Note that the sizes and contents of the structures may
Expand Down
Loading