[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Nick Coghlan
On Fri, 10 Sep 2021, 12:32 am Arnaud Delobelle, wrote: > It probably won't fly but why not bytes.frombyte? > > There's no such thing as a byte type in Python, only bytes, so I want > to argue it makes it clear the argument is a number in the range > 0..255 and the result is a bytes object

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Barry Warsaw
Adding default arguments to int.to_bytes() is both useful on its own merits and kind of too easy *not* to do, so... https://bugs.python.org/issue45155 https://github.com/python/cpython/pull/28265 -Barry > On Sep 9, 2021, at 12:12, Barry Warsaw wrote: > > Signed PGP part > On Sep 9, 2021, at

[Python-Dev] Re: PEP 646 (Variadic Generics): final call for comments

2021-09-09 Thread bas van beek
Hi all, I very much share Stephan's opinion here and look forward to integrating the new PEP 646 variadics into numpy. In the context of numpy (and tensor typing general): the typing of array shapes is a fairly complicated subject and the introduction of variadics will likely play in big role

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Ethan Furman
On 9/9/21 12:12 PM, Barry Warsaw wrote: > On Sep 9, 2021, at 10:56, Ethan Furman wrote: >> On 9/9/21 9:37 AM, Barry Warsaw wrote: >> >>> While I think int.to_bytes() is pretty obscure (I knew about it, forgot about it, and learned >>> about it again!) I’m not so sure it’s any less obscure than a

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Barry Warsaw
On Sep 9, 2021, at 10:56, Ethan Furman wrote: > > On 9/9/21 9:37 AM, Barry Warsaw wrote: > > > While I think int.to_bytes() is pretty obscure (I knew about it, forgot > > about it, and learned > > about it again!) I’m not so sure it’s any less obscure than a proposed > > bytes.fromint(). > >

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Terry Reedy
On 9/9/2021 1:56 PM, Ethan Furman wrote: On 9/9/21 9:37 AM, Barry Warsaw wrote: > While I think int.to_bytes() is pretty obscure (I knew about it, forgot about it, and learned > about it again!) I’m not so sure it’s any less obscure than a proposed bytes.fromint(). > > So why don’t we

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Ethan Furman
On 9/9/21 9:37 AM, Barry Warsaw wrote: > While I think int.to_bytes() is pretty obscure (I knew about it, forgot about it, and learned > about it again!) I’m not so sure it’s any less obscure than a proposed bytes.fromint(). > > So why don’t we just relax int.to_bytes()’s signature to include

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread raymond . hettinger
> I would rather keep `bchr` and lose the `.fromint()` methods. For me, "bchr" isn't a readable name. If I expand mentally expand it to "byte_character", it becomes an oxymoron that opposes what we try teach about bytes and characters being different things. Can you show examples in

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Barry Warsaw
While I think int.to_bytes() is pretty obscure (I knew about it, forgot about it, and learned about it again!) I’m not so sure it’s any less obscure than a proposed bytes.fromint(). So why don’t we just relax int.to_bytes()’s signature to include natural default values:

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Barry Warsaw
On Sep 9, 2021, at 08:53, Christopher Barker wrote: > > I fully admit serious bikeshedding here, but: I think you meant “byte-shedding” :D -Barry signature.asc Description: Message signed with OpenPGP ___ Python-Dev mailing list --

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Ethan Furman
On 9/9/21 8:53 AM, Christopher Barker wrote: > On 9/9/21 7:25 AM, Ethan Furman wrote: >> I'm starting to think the name should be `bytes.bchr` -- it avoids any confusion with the `int.to_bytes` and >> `int.from_bytes` methods, > > are they so different? :-) Yes, they are. Conceptually, one is

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Christopher Barker
I fully admit serious bikeshedding here, but: I'm starting to think the name should be `bytes.bchr` -- it avoids any > confusion with the `int.to_bytes` and > `int.from_bytes` methods, are they so different? :-) In [23]: x.to_bytes(1, 'little') Out[23]: b'A' In [27]: int.from_bytes(b'A',

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Arnaud Delobelle
It probably won't fly but why not bytes.frombyte? There's no such thing as a byte type in Python, only bytes, so I want to argue it makes it clear the argument is a number in the range 0..255 and the result is a bytes object containing this single byte value. Tentatively, Arnaud PS. But truly

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Ethan Furman
On 9/9/21 1:55 AM, Nick Coghlan wrote: > `bytes.fromint` is still the inverse of `ord` for bytes objects, even > without the `bchr` builtin alias. The spelling of the trio is just > `ord`/`bytes.fromint`/`chr` rather than `ord`/`bchr`/`chr`. The fact > the method throws an exception for integers

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Brandt Bucher
Brandt Bucher wrote: > You can even get creative and use the dedicated “pistol” operator… Ah, wait, ignore this example. I got the chr and ord behavior flipped in my head. Brandt ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Ethan Furman
On 9/9/21 3:49 AM, Steven D'Aprano wrote: > We're Python programmers. To Python programmers, the int 20 is not a > space character. That's because int 32 is the space character. ;-) -- ~Ethan~ ___ Python-Dev mailing list -- python-dev@python.org To

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Brandt Bucher
Steven D'Aprano wrote: > TIL :-) > How have I never noticed to_bytes until now? o_O I’m going to go out on a limb here: because it’s rarely ever needed? I mean, the proposed bchr() functionality is crazy simple to implement yourself if you actually *do* need it. You can even get creative and

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Steven D'Aprano
On Thu, Sep 09, 2021 at 12:29:46AM +0100, Rob Cliffe via Python-Dev wrote: > Why not byte() ? Too easy to typo it as bytes(). -- Steve ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Steven D'Aprano
On Wed, Sep 08, 2021 at 05:06:08PM -, Brandt Bucher wrote: > Steven D'Aprano wrote: > > To me, it sounds like should be the opposite of int.from_bytes. > > >>> int.from_bytes(b'Hello world', 'little') > > 121404708502361365413651784 > > >>> bytes.from_int(121404708502361365413651784,

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Steven D'Aprano
On Thu, Sep 09, 2021 at 10:57:26AM +0200, Victor Stinner wrote: > I propose to rename PEP 467 method bytes.fromint(n) to => > bytes.fromchar(n) <= to convert an integer to a single *character*: it > fails if n is not in the [0; 255] range. "char" comes from > "character", as "bchr()" means "bytes

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Antoine Pitrou
On Thu, 9 Sep 2021 12:06:49 +0200 Victor Stinner wrote: > I proposed bytes.byte earlier in this thread: > https://mail.python.org/archives/list/python-dev@python.org/message/KBVVBJL2PHI55Y26Z4FMSCJPER242LFA/ > > Gregory dislikes the name: "I don't *like* to argue over names (the > last stage of

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Victor Stinner
I proposed bytes.byte earlier in this thread: https://mail.python.org/archives/list/python-dev@python.org/message/KBVVBJL2PHI55Y26Z4FMSCJPER242LFA/ Gregory dislikes the name: "I don't *like* to argue over names (the last stage of anything) but I do need to point out how that sounds to read".

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Antoine Pitrou
On Thu, 9 Sep 2021 18:55:04 +1000 Nick Coghlan wrote: > > P.S. The fact that it *didn't* look like the inverse operation for > `int.from_bytes` was one advantage of calling the method > `bytes.fromord` instead of `bytes.fromint`, but I'm still happy the SC > is right that `bytes.fromint` is a

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Victor Stinner
Hum, it seems like this is a confusion between converting a whole bytes *string* to/from an integer, and converting a single *character* to/from an integer. I propose to rename PEP 467 method bytes.fromint(n) to => bytes.fromchar(n) <= to convert an integer to a single *character*: it fails if n

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Nick Coghlan
On Thu, 9 Sept 2021 at 01:46, Ethan Furman wrote: > > On 9/7/21 10:39 PM, Steven D'Aprano wrote: > > On Tue, Sep 07, 2021 at 08:09:33PM -0700, Barry Warsaw wrote: > > > >> I think Nick is on board with bytes.fromint() and no bchr(), and my > >> sense of the sentiment here is that this would