Sebastian Berg <sebast...@sipsolutions.net> added the comment:

Fair enough, we had code that does it the other way, so it seemed "too obvious" 
since the current check seems mainly useful with few kwargs. However, a single 
kwarg is super common in python, while many seem super rare (in any argument 
clinic function)

Which is why I had even trouble finding a function where it could make a 
difference, since it needs many kwargs.

With changes:

sebastian@seberg-x1 ~/python-dev/bin
 % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", 
signed=True)'
1000000 loops, best of 5: 205 nsec per loop
sebastian@seberg-x1 ~/python-dev/bin
 % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", 
signed=True)'
1000000 loops, best of 5: 207 nsec per loop

On master:

sebastian@seberg-x1 ~/python-dev/bin
 % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", 
signed=True)'
1000000 loops, best of 5: 221 nsec per loop
sebastian@seberg-x1 ~/python-dev/bin
 % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", 
signed=True)'
1000000 loops, best of 5: 218 nsec per loop

Which, at close to 5% is barely noticeable, I suppose with more kwargs it could 
start to make a difference. With less than 3, it just does not matter I guess. 
Also, I am currently not sure how likely non-interned strings could actually 
happen. But I am not sure it matters to optimize for them (unless PyArg_From* 
functions use them).

In any case, sorry if this was noise, happy to fix things up or just drop it if 
many kwargs are considered non-existing.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39028>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to