This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients mark.dickinson, serhiy.storchaka
Date 2019-05-19.07:07:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558249621.16.0.461330381438.issue36957@roundup.psfhosted.org>
In-reply-to
Content
It is possible to get yet 10-20% by avoiding to create temporary Python integers for right arguments of shift operations. PR 13416 adds two private functions _PyLong_Rshift() and _PyLong_Lshift() which take the second argument as C size_t instead of Python integer. _PyLong_Lshift() can also be used in factorial() and in float to int comparison.

$ ./python -m timeit -s "from math import isqrt; x = range(2**63-1000, 2**63+1000)" "[isqrt(n) for n in x]"
Unpatched:  200 loops, best of 5: 1.84 msec per loop
Patched:    200 loops, best of 5: 1.51 msec per loop

$ ./python -m timeit -s "from math import isqrt; x = range(2**95-1000, 2**95+1000)" "[isqrt(n) for n in x]"
Unpatched:  100 loops, best of 5: 2.09 msec per loop
Patched:    200 loops, best of 5: 1.75 msec per loop
History
Date User Action Args
2019-05-19 07:07:01serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson
2019-05-19 07:07:01serhiy.storchakasetmessageid: <1558249621.16.0.461330381438.issue36957@roundup.psfhosted.org>
2019-05-19 07:07:01serhiy.storchakalinkissue36957 messages
2019-05-19 07:07:00serhiy.storchakacreate