Skip to content

Commit 4c1cfd7

Browse files
committed
Simplify method dispatch
1 parent 21dcd02 commit 4c1cfd7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Lib/functools.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,8 @@ def __call__(self, /, *args, **kwargs):
10931093
'singledispatchmethod method')
10941094
raise TypeError(f'{funcname} requires at least '
10951095
'1 positional argument')
1096-
if self._skip_bound_arg:
1097-
method = self._dispatch(args[1].__class__)
1098-
else:
1099-
method = self._dispatch(args[0].__class__)
1096+
index = 1 if self._skip_bound_arg else 0
1097+
method = self._dispatch(args[index].__class__)
11001098

11011099
if hasattr(method, "__get__"):
11021100
# If the method is a descriptor, it might be necessary

0 commit comments

Comments
 (0)