Mark Dickinson <dicki...@gmail.com> added the comment:

I'd also really like to avoid a system-dependent default. The danger is that 
code of the form

    some_externally_supplied_integer.to_bytes(length=4)

can be written and thoroughly tested, only to fail unexpectedly some time later 
when that code happens to meet a big-endian machine. In most real-world cases 
with input length >= 1, it's unlikely that the system byteorder is the right 
thing, especially for from_bytes: what you need to know is what endianness the 
integer was encoded with, and that's not likely to be well correlated with the 
endianness that the machine you're running on right now happens to be using. 
(The choice of default obviously doesn't matter in cases where you're encoding 
and decoding on the same system, but there are going to be plenty of cases 
where that's not true.)

This is essentially the same issue that PEP 597 starts to address with 
`open(filename)` with no encoding specified. That system-specific default 
encoding has caused us real issues in production code.

----------
nosy: +mark.dickinson

_______________________________________
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

Reply via email to