Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-87634: remove locking from functools.cached_property#101890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanfurman merged 5 commits intopython:mainfromcarljm:lockfreecp
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
wording changes from review comments
  • Loading branch information
@carljm
carljm committedFeb 23, 2023
commit141a8731204bf0244fab5d4948ada13ae7f6cd86
8 changes: 4 additions & 4 deletionsDoc/library/functools.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,10 +89,10 @@ The :mod:`functools` module defines the following functions:
The *cached_property* does not prevent a possible race condition in
multi-threaded usage. The getter function could run more than once on the
same instance, with the latest run setting the cached value. If the cached
property is idempotent or otherwise not harmful to(in rare cases) run more
than once on aninstance, this is fine. If synchronization is needed,
implement the necessarylocking inside the decorated getter function or
around the cached propertyaccess.
property is idempotent or otherwise not harmful torun more than once on an
instance, this is fine. If synchronization is needed, implement the necessary
locking inside the decorated getter function or around the cached property
access.

Note, this decorator interferes with the operation of :pep:`412`
key-sharing dictionaries. This means that instance dictionaries
Expand Down
12 changes: 6 additions & 6 deletionsDoc/whatsnew/3.12.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -763,12 +763,12 @@ Changes in the Python API

* The undocumented locking behavior of :func:`~functools.cached_property`
is removed, because it locked across all instances of the class, leading to high
lock contention. This means that a cached property getter function could now
occasionally runmore than once for a single instance, if two threads race. For
most simplecached properties (e.g. those that are idempotent and simply
calculate a valuebased on other attributes of the instance) this will be fine.
Ifsynchronization is needed, implement locking within the cached property
getterfunction or around multi-threaded access points.
lock contention. This means that a cached property getter function could now run
more than once for a single instance, if two threads race. For most simple
cached properties (e.g. those that are idempotent and simply calculate a value
based on other attributes of the instance) this will be fine. If
synchronization is needed, implement locking within the cached property getter
function or around multi-threaded access points.


Build Changes
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp