@@ -5533,13 +5533,6 @@ can be used interchangeably to index the same dictionary entry.
55335533 key in d # dict.__contains__
55345534 len(d) # dict.__len__
55355535
5536- These operations may compare keys using :meth: `~object.__eq__ `, which can
5537- execute arbitrary Python code. During such comparisons, the dictionary may
5538- be modified by another thread. For built-in types like :class: `str `,
5539- :class: `int `, and :class: `float `, that implement :meth: `~object.__eq__ ` in C,
5540- the underlying lock is not released during comparisons and this is not a
5541- concern.
5542-
55435536 All other operations from here on hold the per-object lock.
55445537
55455538 Writing or removing a single item is safe to call from multiple threads
@@ -5554,8 +5547,12 @@ can be used interchangeably to index the same dictionary entry.
55545547 d.popitem() # remove and return last item
55555548 d.setdefault(key, v) # insert if missing
55565549
5557- These operations also compare keys, so the same :meth: `~object.__eq__ `
5558- considerations as above apply.
5550+ These operations may compare keys using :meth: `~object.__eq__ `, which can
5551+ execute arbitrary Python code. During such comparisons, the dictionary may
5552+ be modified by another thread. For built-in types like :class: `str `,
5553+ :class: `int `, and :class: `float `, that implement :meth: `~object.__eq__ ` in C,
5554+ the underlying lock is not released during comparisons and this is not a
5555+ concern.
55595556
55605557 The following operations return new objects and hold the per-object lock
55615558 for the duration of the operation:
@@ -5585,7 +5582,7 @@ can be used interchangeably to index the same dictionary entry.
55855582 d |= other_dict # both locked when other_dict is a dict
55865583 d == other_dict # both locked for dict and subclasses
55875584
5588- The equality comparison also compares values using :meth: `~object.__eq__ `,
5585+ All comparison operations also compare values using :meth: `~object.__eq__ `,
55895586 so for non-built-in types the lock may be released during comparison.
55905587
55915588 :meth: `~dict.fromkeys ` locks both the new dictionary and the iterable
0 commit comments