From 73c7bc1fb4ce1fbed83cde4d7270df299d4b6d46 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 22 Oct 2024 15:23:26 -1000 Subject: [PATCH] Try to improve under_cached_property performance (another way) --- src/propcache/_helpers_c.pyx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/propcache/_helpers_c.pyx b/src/propcache/_helpers_c.pyx index 5369e12..a743dc2 100644 --- a/src/propcache/_helpers_c.pyx +++ b/src/propcache/_helpers_c.pyx @@ -27,11 +27,10 @@ cdef class under_cached_property: def __get__(self, inst, owner): if inst is None: return self - cdef dict cache = inst._cache - val = cache.get(self.name, _sentinel) + val = (inst._cache).get(self.name, _sentinel) if val is _sentinel: val = self.wrapped(inst) - cache[self.name] = val + (inst._cache)[self.name] = val return val def __set__(self, inst, value):