[Python-ideas] Fixing the Python 3 bytes constructor

Ethan Furman ethan at stoneleaf.us
Sat Mar 29 17:49:42 CET 2014


On 03/28/2014 03:27 AM, Nick Coghlan wrote:
>
> 3. Deprecate the current "bytes(x)" and "bytearray(x)" int handling as
> not only ambiguous, but actually a genuine bug magnet (it's way too
> easy to accidentally pass a large integer and try to allocate a
> ridiculously large bytes object)

Why do 'bytes' and 'bytearray' have to have exactly the same API?  Having 'bytearray(10)' return a zero filled array is 
fine, as bytearrays are mutable; it just doesn't make sense for 'bytes' which are immutable.

--
~Ethan~


More information about the Python-ideas mailing list