<p dir="ltr">On May 12, 2016 4:29 AM, "Serhiy Storchaka" <<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</a>> wrote:<br>
><br>
> On 12.05.16 02:48, Chris Angelico wrote:<br>
>>>>><br>
>>>>> from time import sleep<br>
>>>>> help(sleep)<br>
>><br>
>> Help on built-in function sleep in module time:<br>
>><br>
>> sleep(...)<br>
>> sleep(seconds)<br>
>><br>
>> Delay execution for a given number of seconds. The argument may be<br>
>> a floating point number for subsecond precision.<br>
>><br>
>>>>> sleep(seconds=1)<br>
>><br>
>> Traceback (most recent call last):<br>
>> File "<stdin>", line 1, in <module><br>
>> TypeError: sleep() takes no keyword arguments<br>
><br>
><br>
> Note that passing positional arguments is much faster than passing keyword arguments even if the function supports them. And the difference can be even larger after pushing Victor's optimization. [1]<br>
> 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 performance.<br>
><br>
> [1] <a href="http://bugs.python.org/issue26814">http://bugs.python.org/issue26814</a><br>
> [2] <a href="http://bugs.python.org/issue23867">http://bugs.python.org/issue23867</a></p>
<p dir="ltr">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.</p>
<p dir="ltr">(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: <a href="https://fatoptimizer.readthedocs.io/en/latest/todo.html#random">https://fatoptimizer.readthedocs.io/en/latest/todo.html#random</a>)</p>