Skip to content

Commit d629e76

Browse files
committed
PERF: made lazy_attribute a tiny bit faster
1 parent ebc2a27 commit d629e76

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

larray/util/misc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,17 @@ class lazy_attribute(object):
665665
"""
666666
def __init__(self, func):
667667
self.func = func
668-
self.__doc__ = self.func.__doc__
668+
self.__doc__ = func.__doc__
669669

670670
# descriptor protocol
671671
# see https://docs.python.org/3/reference/datamodel.html#implementing-descriptors
672672
def __get__(self, instance, owner):
673673
if instance is None:
674674
return self
675675

676-
value = self.func(instance)
677-
setattr(instance, self.func.__name__, value)
676+
func = self.func
677+
value = func(instance)
678+
setattr(instance, func.__name__, value)
678679
return value
679680

680681

0 commit comments

Comments
 (0)