Message401709
That’s okay, Brandt’s improved sys.byteorder is fastest <wink>.
% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "little")'
2000000 loops, best of 11: 94.6 nsec per loop
% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "big")'
2000000 loops, best of 11: 97.8 nsec per loop
% ./python.exe -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10)'
5000000 loops, best of 11: 79.1 nsec per loop
On Sep 12, 2021, at 04:20, Raymond Hettinger <report@bugs.python.org> wrote:
>
> Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:
>
> Interestingly, "little" is faster than "big".
>
> $ python3.10 -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "little")'
> 5000000 loops, best of 11: 82.7 nsec per loop
> $ python3.10 -m timeit -r11 -s 'x=3452452454524' 'x.to_bytes(10, "big")'
> 5000000 loops, best of 11: 90.6 nsec per loop
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue45155>
> _______________________________________ |
|
Date |
User |
Action |
Args |
2021-09-13 16:38:44 | barry | set | recipients:
+ barry, rhettinger, mark.dickinson, ncoghlan, vstinner, petr.viktorin, ethan.furman, serhiy.storchaka, veky, brandtbucher |
2021-09-13 16:38:44 | barry | link | issue45155 messages |
2021-09-13 16:38:44 | barry | create | |
|