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 contain
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 1
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 i
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
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().
> >
>
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 jus
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 n
> 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 existing
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:
int.to_bytes(length
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@pytho
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
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', 'litt
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 I
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
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
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 u
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 use
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
ht
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, 'l
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
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 a
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".
https
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 mor
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 i
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 be
25 matches
Mail list logo