From e2390f0c1984e8a1323ae34b1bbd0946add17b92 Mon Sep 17 00:00:00 2001 From: Tamas Gal <tgal@km3net.de> Date: Wed, 4 Mar 2020 11:38:51 +0100 Subject: [PATCH] Cleanup cached_property decorator --- km3io/offline.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/km3io/offline.py b/km3io/offline.py index c331df9..0722cc6 100644 --- a/km3io/offline.py +++ b/km3io/offline.py @@ -11,13 +11,15 @@ BASKET_CACHE_SIZE = 110 * 1024**2 class cached_property: - def __init__(self, func): - self.func = func + """A simple cache decorator for properties.""" + def __init__(self, function): + self.function= function def __get__(self, obj, cls): - if obj is None: return self - value = obj.__dict__[self.func.__name__] = self.func(obj) - return value + if obj is None: + return self + prop = obj.__dict__[self.function.__name__] = self.function(obj) + return prop class OfflineKeys: -- GitLab