Skip to content

Commit

Permalink
Compare try performance
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 23, 2024
1 parent b7be10f commit ebb2b3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/propcache/_helpers_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ cdef class under_cached_property:
if inst is None:
return self
cdef dict cache = inst._cache
val = cache.get(self.name, _sentinel)
if val is _sentinel:
try:
return cache[self.name]
except KeyError:
val = self.wrapped(inst)
cache[self.name] = val
return val
return val

def __set__(self, inst, value):
raise AttributeError("cached property is read-only")
Expand Down

0 comments on commit ebb2b3f

Please sign in to comment.