[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: SimpleNamespace vs object

2021-03-02 Thread Sven R. Kunze
On 18.02.21 05:43, Chris Angelico wrote: On Thu, Feb 18, 2021 at 1:59 PM Ben Rudiak-Gould wrote: It seems to me that all you'd have to do is add a line or two to the add_dict logic in type_new so that instances of object get a dict. Then instances of object would get a dict, and nothing

[Python-ideas] Integer concatenation to byte string

2021-03-02 Thread Stephen J. Turnbull
mmax42...@gmail.com writes: > 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. I don't work with bytes much, so I won't comment on the proposal itself. But as

[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. > >