Message401556
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. |
|
Date |
User |
Action |
Args |
2021-09-10 07:04:00 | mark.dickinson | set | recipients:
+ mark.dickinson, barry, rhettinger, ncoghlan, ethan.furman, serhiy.storchaka, veky |
2021-09-10 07:03:59 | mark.dickinson | set | messageid: <1631257439.99.0.904568595094.issue45155@roundup.psfhosted.org> |
2021-09-10 07:03:59 | mark.dickinson | link | issue45155 messages |
2021-09-10 07:03:59 | mark.dickinson | create | |
|