You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
The text was updated successfully, but these errors were encountered:
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...
The text was updated successfully, but these errors were encountered: