You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pytho...@python.org
Currently, the only way to concatenate an integer to a bytes object is by converting the integer to bytes with a function call before concatenating. And there is no way to make a mutable bytes object without a function call. And bytearray function calls are 9-10x slower than b-strings.
I propose an array-type string like the, or for the bytearray. It would work as a mutable b-string, as
foo = a"\x00\x01\x02abcÿ" # a-string, a mutable bytes object. foo[0] = 123 # Item assignment foo+= 255 # Works the same as bytesvariable+=b"ÿ" foo+= a"\x255\x00" # Concatenation with itself foo+= b"\x255\x00" # Cross compatibility with bytes objects.
This would be processed the same as, or would be the bytearray,
>>> type(a"\x00\x01\x02abcÿ") <class 'bytearray'>
Martin (gzlist) via Python-Dev
unread,
Mar 5, 2021, 10:39:45 AM3/5/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Memz, Python Dev
On Tue, 2 Mar 2021 at 21:44, Memz <mmax...@gmail.com> wrote:
>
> foo+= 255 # Works the same as bytesvariable+=b"ÿ"
foo = b"%b%d" % (foo, 255)
> foo+= a"\x255\x00" # Concatenation with itself
foo = b"%b%b" % (foo, foo)
See PEP461:
Adding % formatting to bytes and bytearray
<https://www.python.org/dev/peps/pep-0461/>
"With Python 3 and the split between str and bytes, one small but
important area of programming became slightly more difficult, and much
more painful -- wire format protocols."