
This patch seems very complete, with only the API to hammered out. Here is my summary of some options: method names: patch behavior: int.as_bytes / int.frombytes int.as_bytes / int.from_bytes int.asbytes / int.frombytes Endianness: patch behavior: default flag: little_endian=False byteorder option accepting 'big' or 'little', this can also accept sys.byteorder sign: patch behavior: default flag: signed=True maybe unsigned as the default? byte length: patch behavior: fixed_length=None other names: length, bytelength As for my own opinions: I think the method names should have consistent underscore usage. I think it is important to have all of big, little, and native as byteorder options, but I would be against having native as the default. I think it is unclean for core functionality to be platform dependent (there may be some examples of this that I'm not thinking of though). One option would be to have the defaults of int.as_bytes mirror the hex builtin function, eg big endian and unsigned. This way it could be more consistent with related functionality already in the core. Thoughts? -Eric On Sat, Aug 15, 2009 at 20:23, Mark Dickinson<dickinsm@gmail.com> wrote:
On Mon, Aug 10, 2009 at 2:13 PM, Nick Coghlan<ncoghlan@gmail.com> wrote:
Bytes to int:
[...] Int to bytes:
[...]
Alexandre Vassalotti has posted a patch at
http://bugs.python.org/issue1023290
that implements methods very much like the ones that Nick describes.
Mark