[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Eric V. Smith
On 5/20/2021 3:24 PM, Ronald Oussoren via Python-Dev wrote: On 20 May 2021, at 19:10, Luciano Ramalho > wrote: I'd like to learn about use cases where `...` (a.k.a. `Ellipsis`) is not a good sentinel. It's a pickable singleton testable with `is`, readily

[Python-Dev] Re: Critique of PEP 657 -- Include Fine Grained Error Locations in Tracebacks

2021-05-20 Thread Pablo Galindo Salgado
> Hopefully if we add more pseudokeywords in the future it won't break the ability to parse traceback spans. It won't because soft keywords are now handled natively with the peg parser (as "match" and "case" now) instead of hacked into the tokenizer :) On Fri, 21 May 2021 at 01:55, Nathaniel

[Python-Dev] Re: Critique of PEP 657 -- Include Fine Grained Error Locations in Tracebacks

2021-05-20 Thread Nathaniel Smith
On Wed, May 19, 2021 at 7:28 PM Pablo Galindo Salgado wrote: >> >> Excellent point! Do you know how reliable this is in practice, i.e. >> what proportion of bytecode source spans are something you can >> successfully pass to ast.parse? If it works it's obviously nicer, but >> I can't tell how

[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-20 Thread Christopher Barker
I find this whole conversation confusing -- does anyone really think a substantial performance boost to cPython is not a "good thing"? Worth the work? Maybe not, but it seems that Mark, Guido, and MS think it is -- more power to them! Anyway: potential 10% or 20% speedups in Python I believe

[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-20 Thread Stephen J. Turnbull
Oscar Benjamin writes: > The break even point where both implementations take equal time is > around about 5% density. What that means is that for a 1000 x 1000 > matrix with 10% of elements nonzero it is faster to ask flint to > construct an enormous dense matrix and perform a huge number of

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread micro codery
> > But it nevertheless feels like a bit of an abuse - the original point >> > of ellipsis was for indexing, and in particular complex slices like >> > a[1:20:2, ..., 3:5]. That usage is common in numpy, as I understand >> > it, >> Interesting -- do you know what ... means in that context? >>

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Tal Einat
On Thu, May 20, 2021 at 10:37 PM David Mertz wrote: > > The scenario I'm thinking about is like this: > > (base) 84-tmp % python > Python 3.9.1 (default, Dec 11 2020, 14:32:07) > [GCC 7.3.0] :: Anaconda, Inc. on linux > Type "help", "copyright", "credits" or "license" for more information. > >>>

[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-20 Thread Terry Reedy
On 5/20/2021 10:49 AM, Oscar Benjamin wrote: On Thu, 20 May 2021 at 04:58, Terry Reedy wrote: I believe the ratio for the sort of numerical computing getting bogus complaints is sometimes more like 95% of *time* in compiled C and only, say, 5% of *time* in the Python interpreter. So even if

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread David Mertz
The scenario I'm thinking about is like this: (base) 84-tmp % python Python 3.9.1 (default, Dec 11 2020, 14:32:07) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pickle >>> cheap_sentinel = object() >>> id(cheap_sentinel)

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Sebastian Berg
On Thu, 2021-05-20 at 19:00 +0100, Paul Moore wrote: > On Thu, 20 May 2021 at 18:13, Luciano Ramalho > wrote: > > > > I'd like to learn about use cases where `...` (a.k.a. `Ellipsis`) > > is > > not a good sentinel. It's a pickable singleton testable with `is`, > > readily available, and

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Ronald Oussoren via Python-Dev
> On 20 May 2021, at 19:10, Luciano Ramalho wrote: > > I'd like to learn about use cases where `...` (a.k.a. `Ellipsis`) is > not a good sentinel. It's a pickable singleton testable with `is`, > readily available, and extremely unlikely to appear in a data stream. > Its repr is "Ellipsis". >

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Paul Moore
On Thu, 20 May 2021 at 20:06, Ethan Furman wrote: > > On 5/20/21 11:00 AM, Paul Moore wrote: > > > But it nevertheless feels like a bit of an abuse - the original point > > of ellipsis was for indexing, and in particular complex slices like > > a[1:20:2, ..., 3:5]. That usage is common in

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread David Mertz
On Thu, May 20, 2021 at 3:03 PM Ethan Furman wrote: > > But it nevertheless feels like a bit of an abuse - the original point > > of ellipsis was for indexing, and in particular complex slices like > > a[1:20:2, ..., 3:5]. That usage is common in numpy, as I understand > > it, > Interesting

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Ethan Furman
On 5/20/21 10:47 AM, David Mertz wrote: > On Thu, May 20, 2021 at 6:21 AM Tal Einat wrote: >> I think it's worth preserving the idiom of comparing sentinels using >> `is`, as we do for `None` and other existing sentinel values. It's >> relatively easy to do, such as by using a single-value Enum

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Ethan Furman
On 5/20/21 11:00 AM, Paul Moore wrote: > But it nevertheless feels like a bit of an abuse - the original point > of ellipsis was for indexing, and in particular complex slices like > a[1:20:2, ..., 3:5]. That usage is common in numpy, as I understand > it, Interesting -- do you know what ...

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread David Mertz
On Thu, May 20, 2021, 2:11 PM Chris Angelico > Probably the easiest way would be to have some kind of unique > identifier (a fully-qualified name) that can be pickled, and then any > time you attempt to construct a Sentinel with that identifier, it's > guaranteed to return the same object.

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Chris Angelico
On Fri, May 21, 2021 at 3:51 AM David Mertz wrote: > > On Thu, May 20, 2021 at 6:21 AM Tal Einat wrote: >> >> On Sat, May 15, 2021 at 2:09 AM David Mertz wrote: >> > Just add a ._uuid attribute and have object equality follow equality of >> > that attribute. There's no reason to expose that in

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Paul Moore
On Thu, 20 May 2021 at 18:13, Luciano Ramalho wrote: > > I'd like to learn about use cases where `...` (a.k.a. `Ellipsis`) is > not a good sentinel. It's a pickable singleton testable with `is`, > readily available, and extremely unlikely to appear in a data stream. > Its repr is "Ellipsis".

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread David Mertz
On Thu, May 20, 2021 at 6:21 AM Tal Einat wrote: > On Sat, May 15, 2021 at 2:09 AM David Mertz wrote: > > Just add a ._uuid attribute and have object equality follow equality of > that attribute. There's no reason to expose that in the .__repr__, but it > would be inspectable in concept. > > I

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Luciano Ramalho
I'd like to learn about use cases where `...` (a.k.a. `Ellipsis`) is not a good sentinel. It's a pickable singleton testable with `is`, readily available, and extremely unlikely to appear in a data stream. Its repr is "Ellipsis". If you don't like the name for this purpose, you can always define

[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-20 Thread Oscar Benjamin
On Thu, 20 May 2021 at 04:58, Terry Reedy wrote: > > On 5/13/2021 4:18 AM, Mark Shannon wrote: > > > If a program does 95% of its work in a C++ library and 5% in Python, it > > can easily spend the majority of its time in Python because CPython is a > > lot slower than C++ (in general). > > I

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Victor Stinner
IMO you should consider writing a PEP to enhance sentinels in Python, and maybe even provide a public API for sentinels in general. Victor ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Tal Einat
On Sat, May 15, 2021 at 2:09 AM David Mertz wrote: > > I think it's more future-looking to allow pickle round-tripping. I tend to agree. > Just add a ._uuid attribute and have object equality follow equality of that > attribute. There's no reason to expose that in the .__repr__, but it would

[Python-Dev] Re: The repr of a sentinel

2021-05-20 Thread Tal Einat
I've created a poll on this subject: https://discuss.python.org/t/sentinel-values-in-the-stdlib/8810 On Fri, May 14, 2021 at 10:33 PM Tal Einat wrote: > > On Fri, May 14, 2021 at 12:45 PM Steve Dower wrote: > > > > On 14May2021 0622, micro codery wrote: > > > > > > There was a discussion a