On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote:
Deprecation of current "zero-initialised sequence" behaviour ------------------------------------------------------------
Currently, the ``bytes`` and ``bytearray`` constructors accept an integer argument and interpret it as meaning to create a zero-initialised sequence of the given size::
>>> bytes(3) b'\x00\x00\x00' >>> bytearray(3) bytearray(b'\x00\x00\x00')
This PEP proposes to deprecate that behaviour in Python 3.6, and remove it entirely in Python 3.7.
No other changes are proposed to the existing constructors.
Does it need to be *actually* removed? That does break existing code for not a lot of benefit. Yes, the default constructor is a little wonky, but with the addition of the new constructors, and the fact that you're not proposing to eventually change the default constructor, removal seems unnecessary. Besides, once it's removed, what would `bytes(3)` actually do? The PEP doesn't say. Also, since you're proposing to add `bytes.byte(3)` have you considered also adding an optional count argument? E.g. `bytes.byte(3, count=7)` would yield b'\x03\x03\x03\x03\x03\x03\x03'. That seems like it could be useful. Cheers, -Barry