Skip to content

Commit

Permalink
Merge pull request #6 from eendebakpt/singledispatchmethod3b
Browse files Browse the repository at this point in the history
Eliminate caching variable
  • Loading branch information
eendebakpt authored Aug 1, 2023
2 parents ca691e8 + e8eeedd commit 307f0c1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,13 +949,11 @@ def __get__(self, obj, cls=None):
try:
_method = self._method_cache[obj]
except TypeError:
self._all_weakrefable_instances = caching = False
self._all_weakrefable_instances = False
except KeyError:
caching = True
pass
else:
return _method
else:
caching = False

def _method(*args, **kwargs):
method = self.dispatcher.dispatch(args[0].__class__)
Expand All @@ -965,7 +963,7 @@ def _method(*args, **kwargs):
_method.register = self.register
update_wrapper(_method, self.func)

if caching:
if self._all_weakrefable_instances:
self._method_cache[obj] = _method

return _method
Expand Down

0 comments on commit 307f0c1

Please sign in to comment.