Re: PEP 467 feedback from the Steering Council
There is some discussion going on in bpo-45155 about what the default value of the `byteorder` argument should be for int.to_bytes() and int.from_bytes(): https://bugs.python.org/issue45155 I’ve created a short Discourse poll if you’d like to weigh in. https://discuss.python.org/t/what-should-be-the-default-value-for-int-to-byt... Cheers, -Barry
Le 13/09/2021 à 19:01, Barry Warsaw a écrit :
There is some discussion going on in bpo-45155 about what the default value of the `byteorder` argument should be for int.to_bytes() and int.from_bytes():
Hello, a use case and feature request: I have used int.to_bytes() and int.from_bytes() interactively at the Python REPL for picking apart pieces of binary data files, in contexts of debugging or casual reverse-engineering (I could have used `struct`, but then I would have needed to reread the doc ;-) For this use case, setting defaults for the arguments is obviously beneficial (less typing), and the most comfortable defaults would be: - for `length`, the minimum length needed to encode the integer (I mostly care for the content, not the leading or trailing zeros); - for `byteorder`, preferably a fixed default so I can remember it once and for all, and in any case something rather than None (if the bytes are reversed, I'll still recognize them). Whatever comes out of this discussion, it would be nice if the `byteorder` constants got a one-character short form, be it 'l' and 'b' for discoverability, or '<' and '>' for consistency with `struct`. Having to type 'little' is painfully long at the REPL. Cheers, Baptiste
participants (2)
-
Baptiste Carvello
-
Barry Warsaw