Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locking strategy is wrong #250

Open
ztane opened this issue Mar 11, 2021 · 0 comments
Open

Locking strategy is wrong #250

ztane opened this issue Mar 11, 2021 · 0 comments

Comments

@ztane
Copy link

ztane commented Mar 11, 2021

Now that the locking cached_property was adapted into Python standard library, I'd note here too that the threaded_cached_property locking strategy is wrong for many use cases, and I've written an issue in bugs.python.org.

The reason is that a descriptor is not instantiated for every object instance - they indeed exist only once for each class. Thus if there are multiple instances of the class, then all these would share the same one lock, even though the caches are independent. And if there is only one instance of a class then it is rather Pythonic to not write a class at all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant