@@ -959,15 +959,12 @@ def __isabstractmethod__(self):
959959### cached_property() - computed once per instance, cached as attribute
960960################################################################################
961961
962- _NOT_FOUND = object ()
963-
964962
965963class cached_property :
966964 def __init__ (self , func ):
967965 self .func = func
968966 self .attrname = None
969967 self .__doc__ = func .__doc__
970- self .lock = RLock ()
971968
972969 def __set_name__ (self , owner , name ):
973970 if self .attrname is None :
@@ -992,21 +989,15 @@ def __get__(self, instance, owner=None):
992989 f"instance to cache { self .attrname !r} property."
993990 )
994991 raise TypeError (msg ) from None
995- val = cache .get (self .attrname , _NOT_FOUND )
996- if val is _NOT_FOUND :
997- with self .lock :
998- # check if another thread filled cache while we awaited lock
999- val = cache .get (self .attrname , _NOT_FOUND )
1000- if val is _NOT_FOUND :
1001- val = self .func (instance )
1002- try :
1003- cache [self .attrname ] = val
1004- except TypeError :
1005- msg = (
1006- f"The '__dict__' attribute on { type (instance ).__name__ !r} instance "
1007- f"does not support item assignment for caching { self .attrname !r} property."
1008- )
1009- raise TypeError (msg ) from None
992+ val = self .func (instance )
993+ try :
994+ cache [self .attrname ] = val
995+ except TypeError :
996+ msg = (
997+ f"The '__dict__' attribute on { type (instance ).__name__ !r} instance "
998+ f"does not support item assignment for caching { self .attrname !r} property."
999+ )
1000+ raise TypeError (msg ) from None
10101001 return val
10111002
10121003 __class_getitem__ = classmethod (GenericAlias )
0 commit comments