Author barry
Recipients barry, brandtbucher, ethan.furman, mark.dickinson, ncoghlan, petr.viktorin, rhettinger, serhiy.storchaka, veky, vstinner
Date 2021-09-13.16:38:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <F5BC64BE-D044-4E91-B664-891549D01D74@python.org>
In-reply-to <1631445658.16.0.770802421368.issue45155@roundup.psfhosted.org>
Content
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>
> _______________________________________
History
Date User Action Args
2021-09-13 16:38:44barrysetrecipients: + barry, rhettinger, mark.dickinson, ncoghlan, vstinner, petr.viktorin, ethan.furman, serhiy.storchaka, veky, brandtbucher
2021-09-13 16:38:44barrylinkissue45155 messages
2021-09-13 16:38:44barrycreate