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 = 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,
On Tue, 2 Mar 2021 at 21:44, Memz email@example.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)
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."