On May 12, 2016 4:29 AM, "Serhiy Storchaka" <storchaka@gmail.com> wrote:
On 12.05.16 02:48, Chris Angelico wrote:
from time import sleep help(sleep)
Help on built-in function sleep in module time:
sleep(...) sleep(seconds)
Delay execution for a given number of seconds. The argument may be a floating point number for subsecond precision.
sleep(seconds=1)
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sleep() takes no keyword arguments
Note that passing positional arguments is much faster than passing
Other optimizations (like [2]) can be applied only for functions that support only positional parameters. Thus passing positional arguments and having functions that support only positional parameters is important for
keyword arguments even if the function supports them. And the difference can be even larger after pushing Victor's optimization. [1] performance.
[1] http://bugs.python.org/issue26814 [2] http://bugs.python.org/issue23867
Worth noting that a guarding optimizer, or a "hinted" optimizer (like a decorator on the caller which locks in specified names for functions), can theoretically optimize away those keyword args to positional args. So if performance is important, there could be a future where readability doesn't have to be sacrificed, and this idiom would put pressure on creating that future. (Victor's other work on optimization is about both of those kinds of optimizers, I think. I suggested this optimization, but never did anything about it. It's on the todo list: https://fatoptimizer.readthedocs.io/en/latest/todo.html#random)