Staging
v0.5.1
https://github.com/python/cpython
Revision 049039832da3d02592d680cebf71ab8a665a6564 authored by Antoine Pitrou on 10 June 2020, 20:37:21 UTC, committed by GitHub on 10 June 2020, 20:37:21 UTC


The doccumentation at https://docs.python.org/3.10/library/weakref.html cautions that the `WeakKeyDictionary` and `WeakValueDictionary` are susceptible to the problem of dictionary mutation during iteration.

These notes present the user with a problem that has no easy solution.

I dug into the implementation and found that fortunately, Antoine Pitrou already addressed this challenge (10 years ago!) by introducing an `_IterationGuard` context manager to the implementation, which delays mutation while an iteration is in progress.

I asked for confirmation and @pitrou agreed that these notes could be removed:
https://github.com/python/cpython/commit/c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438.
(cherry picked from commit 1642c0ef750f96664a98cadb09301d492098d2fb)

Co-authored-by: Daniel Fortunov <asqui@users.noreply.github.com>

Automerge-Triggered-By: @pitrou
1 parent 4b378ac
History
Tip revision: 049039832da3d02592d680cebf71ab8a665a6564 authored by Antoine Pitrou on 10 June 2020, 20:37:21 UTC
[3.7] bpo-40895: Update weakref documentation to remove old warnings (GH-20687) (GH-20793)
Tip revision: 0490398
File Mode Size
__init__.py -rw-r--r-- 1.1 KB
base_events.py -rw-r--r-- 68.2 KB
base_futures.py -rw-r--r-- 2.0 KB
base_subprocess.py -rw-r--r-- 8.6 KB
base_tasks.py -rw-r--r-- 2.1 KB
constants.py -rw-r--r-- 888 bytes
coroutines.py -rw-r--r-- 8.4 KB
events.py -rw-r--r-- 25.6 KB
format_helpers.py -rw-r--r-- 2.3 KB
futures.py -rw-r--r-- 12.5 KB
locks.py -rw-r--r-- 15.5 KB
log.py -rw-r--r-- 124 bytes
proactor_events.py -rw-r--r-- 25.1 KB
protocols.py -rw-r--r-- 6.9 KB
queues.py -rw-r--r-- 7.8 KB
runners.py -rw-r--r-- 2.0 KB
selector_events.py -rw-r--r-- 36.8 KB
sslproto.py -rw-r--r-- 26.3 KB
streams.py -rw-r--r-- 24.0 KB
subprocess.py -rw-r--r-- 7.1 KB
tasks.py -rw-r--r-- 30.0 KB
transports.py -rw-r--r-- 9.9 KB
unix_events.py -rw-r--r-- 40.0 KB
windows_events.py -rw-r--r-- 29.5 KB
windows_utils.py -rw-r--r-- 5.0 KB

back to top