
Aug. 11, 2009
3:08 a.m.
Nick Coghlan wrote:
As far as bytearray goes, my original post did suggest that approach (i.e. class methods on the target types), but that then gets tedious as every new type that wants to support conversion from an integer needs to either go through one of the existing types or else have it's own C extension call the underlying C API directly.
I'd suggest that int.to_bytes should take an optional destination parameter, and it should accept any object having a mutable buffer interface. That would keep all the int-related methods with the int class, without restricting the source or destination to any particular type. -- Greg