Barry A. Warsaw <ba...@python.org> added the comment: 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 <rep...@bugs.python.org> wrote: > > Raymond Hettinger <raymond.hettin...@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 <rep...@bugs.python.org> > <https://bugs.python.org/issue45155> > _______________________________________ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45155> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com