[Python-ideas] Re: Integer concatenation to byte string

2021-03-03 Thread Random832
On Wed, Mar 3, 2021, at 04:09, Barry Scott wrote: > I was thinking of the C functions that are executed in ceval.c to run > the interpreter for any byte code. In that case, it's not clear how your proposed syntax would not have the same overhead [especially your suggestion of a += operator]

[Python-ideas] Re: Integer concatenation to byte string

2021-03-03 Thread Barry Scott
> On 2 Mar 2021, at 23:49, Steven D'Aprano wrote: > > > [Barry] >> All python byte code is interpreted by calling functions. They take >> time and resources. > > That's not entirely correct. Literals such as text strings, ints and > floats get compiled directly into the byte-code. Now of

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Steven D'Aprano
Memz, Please keep your responses on the mailing list. On Tue, Mar 02, 2021 at 08:07:39PM +, Barry Scott wrote: > > On 2 Mar 2021, at 13:04, Memz wrote: > > > > There is no specific scenario it solves. The lack of efficiency of > > the timed code should speak for itself. Non-mutable bytes

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Eryk Sun
On 3/1/21, mmax42...@gmail.com wrote: > And there is no way to make a mutable bytes object without a function call. Since a code object is immutable, the proposed bytearray display form would still require an internal operation that constructs a bytearray from a bytes object. For example,

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Chris Angelico
On Tue, Mar 2, 2021 at 5:03 AM wrote: > > 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. > > I propose an

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Steven D'Aprano
On Mon, Mar 01, 2021 at 06:01:24PM -, mmax42...@gmail.com wrote: > I propose an array-type string like the, or for the bytearray. It would work > as a mutable b-string, as [...] > This would be processed the same as, or would be the bytearray, Then just use bytearray. I think the only new

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Barry Scott
We where no longer on the ideas list... > On 2 Mar 2021, at 13:04, Memz wrote: > > There is no specific scenario it solves. The lack of efficiency of the timed > code should speak for itself. Non-mutable bytes is a limit of python, since > it's reliant on using function calls. > >

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Greg Ewing
On 2/03/21 7:01 am, mmax42...@gmail.com wrote: 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. No, it's not: >>> b = bytearray() >>> b.append(42) >>> b bytearray(b'*') -- Greg

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Barry Scott
> On 1 Mar 2021, at 18:01, mmax42...@gmail.com wrote: > > 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. > >