Hello, On Tue, 07 Jun 2016 13:28:13 -0700 Ethan Furman <et...@stoneleaf.us> wrote:
> Minor changes: updated version numbers, add punctuation. > > The current text seems to take into account Guido's last comments. > > Thoughts before asking for acceptance? > > [] > 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. Why the desire to break applications of thousands and thousands of people? Besides, bytes(3) behavior is very logical. Everyone who knows what malloc(3) does also knows what bytes(3) does. Who doesn't, can learn, and eventually be grateful that learning Python actually helped them to learn other language as well. [] > Addition of explicit "single byte" constructors > ----------------------------------------------- > > As binary counterparts to the text ``chr`` function, this PEP > proposes the addition of an explicit ``byte`` alternative constructor > as a class method on both ``bytes`` and ``bytearray``:: > > >>> bytes.byte(3) > b'\x03' > >>> bytearray.byte(3) > bytearray(b'\x03') > > These methods will only accept integers in the range 0 to 255 > (inclusive):: > > >>> bytes.byte(512) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ValueError: bytes must be in range(0, 256) > > >>> bytes.byte(1.0) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'float' object cannot be interpreted as an integer > > The documentation of the ``ord`` builtin will be updated to > explicitly note that ``bytes.byte`` is the inverse operation for > binary data, while ``chr`` is the inverse operation for text data. The documentation should probably also mention that bytes.byte(x) is equivalent to x.to_bytes(1, "little"). [] -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com