Skip to content

Commit 05c9474

Browse files
authored
[3.13] gh-142518: Define lock-free and per-object lock (GH-144548) (#144707)
(cherry picked from commit 12dbae4)
1 parent a5b1952 commit 05c9474

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Doc/glossary.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,16 @@ Glossary
882882
to locks exist such as queues, producer/consumer patterns, and
883883
thread-local state. See also :term:`deadlock`, and :term:`reentrant`.
884884

885+
lock-free
886+
An operation that does not acquire any :term:`lock` and uses atomic CPU
887+
instructions to ensure correctness. Lock-free operations can execute
888+
concurrently without blocking each other and cannot be blocked by
889+
operations that hold locks. In :term:`free-threaded <free threading>`
890+
Python, built-in types like :class:`dict` and :class:`list` provide
891+
lock-free read operations, which means other threads may observe
892+
intermediate states during multi-step modifications even when those
893+
modifications hold the :term:`per-object lock`.
894+
885895
loader
886896
An object that loads a module.
887897
It must define the :meth:`!exec_module` and :meth:`!create_module` methods
@@ -1139,6 +1149,16 @@ Glossary
11391149
<faq-argument-vs-parameter>`, the :class:`inspect.Parameter` class, the
11401150
:ref:`function` section, and :pep:`362`.
11411151

1152+
per-object lock
1153+
A :term:`lock` associated with an individual object instance rather than
1154+
a global lock shared across all objects. In :term:`free-threaded
1155+
<free threading>` Python, built-in types like :class:`dict` and
1156+
:class:`list` use per-object locks to allow concurrent operations on
1157+
different objects while serializing operations on the same object.
1158+
Operations that hold the per-object lock prevent other locking operations
1159+
on the same object from proceeding, but do not block :term:`lock-free`
1160+
operations.
1161+
11421162
path entry
11431163
A single location on the :term:`import path` which the :term:`path
11441164
based finder` consults to find modules for importing.

0 commit comments

Comments
 (0)