Skip to content

Commit f1b2cbe

Browse files
authored
Performance improvement (#1)
* Removed expensive call to inspect.getcallargs() where a simple if statement would do * Fixed not handling _pause as a positional argument
1 parent ba75225 commit f1b2cbe

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pydirectinput/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,12 +1751,16 @@ def _genericPyDirectInputChecks(
17511751
'''
17521752
@functools.wraps(wrappedFunction)
17531753
def wrapper(*args: _PS.args, **kwargs: _PS.kwargs) -> _RT:
1754-
funcArgs: dict[str, Any] = (
1755-
inspect.getcallargs(wrappedFunction, *args, **kwargs)
1756-
)
1754+
if '_pause' in kwargs:
1755+
_pause = kwargs['_pause']
1756+
else:
1757+
funcArgs: dict[str, Any] = (
1758+
inspect.getcallargs(wrappedFunction, *args, **kwargs)
1759+
)
1760+
_pause = funcArgs.get("_pause")
17571761
_failSafeCheck()
17581762
returnVal: _RT = wrappedFunction(*args, **kwargs)
1759-
_handlePause(funcArgs.get("_pause"))
1763+
_handlePause(_pause)
17601764
return returnVal
17611765
return wrapper
17621766
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)