Optimized lazy wrappers a bit.
This avoids an extra __getattribute__() call for self._wrapped.
This commit is contained in:
parent
95b7d01d38
commit
5659015d3c
|
@ -88,9 +88,10 @@ class LazySettings(LazyObject):
|
|||
|
||||
def __getattr__(self, name):
|
||||
"""Return the value of a setting and cache it in self.__dict__."""
|
||||
if self._wrapped is empty:
|
||||
if (_wrapped := self._wrapped) is empty:
|
||||
self._setup(name)
|
||||
val = getattr(self._wrapped, name)
|
||||
_wrapped = self._wrapped
|
||||
val = getattr(_wrapped, name)
|
||||
|
||||
# Special case some settings which require further modification.
|
||||
# This is done here for performance reasons so the modified value is cached.
|
||||
|
|
|
@ -262,9 +262,10 @@ empty = object()
|
|||
|
||||
def new_method_proxy(func):
|
||||
def inner(self, *args):
|
||||
if self._wrapped is empty:
|
||||
if (_wrapped := self._wrapped) is empty:
|
||||
self._setup()
|
||||
return func(self._wrapped, *args)
|
||||
_wrapped = self._wrapped
|
||||
return func(_wrapped, *args)
|
||||
|
||||
inner._mask_wrapped = False
|
||||
return inner
|
||||
|
|
Loading…
Reference in New Issue