[Python-ideas] Re: On the history and usage of vars [was Re: Re: Unpack operator "**" and Mapping]

2020-12-30 Thread Steve Barnes
>len() is an important abstraction for containers, and its usage deserves a >short name (just like unary minus and abs() for numbers). This is crucial even >though >you have to use its "true name"

[Python-ideas] Re: Fixing and improving statement caching in sqlite3

2020-12-30 Thread Inada Naoki
On Thu, Dec 31, 2020 at 8:43 AM James Oldfield wrote: > > 1. My first suggestion is to replace the odd cache logic with a > straightforward classic LRU cache. I'm hoping this is uncontroversial, > but I can imagine there might be programs that somehow depend on the > current behaviour. But my

[Python-ideas] Re: On the history and usage of vars [was Re: Re: Unpack operator "**" and Mapping]

2020-12-30 Thread Guido van Rossum
On Wed, Dec 30, 2020 at 5:01 PM Steven D'Aprano wrote: > On Tue, Dec 29, 2020 at 09:02:10AM -0800, Guido van Rossum wrote: > > On Tue, Dec 29, 2020 at 8:11 AM Steven D'Aprano > wrote: > > > To the contrary, vars() is something I added to the language for the > > benefit of REPL users (like

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-30 Thread Brendan Barnwell
On 2020-12-29 15:01, Christopher Barker wrote: along with a COMPLETE list of the language features that make use of that protocol. That is pretty much impossible -- that's kind of the point of a protocol -- it can be used in arbitrary places in arbitrary code. would you expect a

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-30 Thread Brendan Barnwell
On 2020-12-30 19:26, Christopher Barker wrote: The trick here, in this context, is that something doesn't need to be a fully functioning Mapping to be unpacked. But there are a handful of places where a subset of the Mapping API is needed (apparently .keys() and __getitem__, with a particular

[Python-ideas] Re: Right way to dataclass -> dict conversion.

2020-12-30 Thread Christopher Barker
I think you are getting a bit tangled up in the distinction between what I call "data" and "code": dicts are data dataclasses are code. Granted, in Python this line can be blurry, but I think it's helpful to think about it that way. Thinking of it this way, dataclasses.asdict() is converting

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-30 Thread Christopher Barker
On Tue, Dec 29, 2020 at 4:24 PM Greg Ewing wrote: > The library reference doesn't seem to use the terms "sequence protocol" > and "mapping protocol". It talks about "sequence types" and "mapping > types", but doesn't use the word "protocol" in relation to them. > The only one I've really seen

[Python-ideas] Re: On the history and usage of vars [was Re: Re: Unpack operator "**" and Mapping]

2020-12-30 Thread Christopher Barker
On Wed, Dec 30, 2020 at 5:01 PM Steven D'Aprano wrote: > Speaking of slots, I've often been annoyed that there is no abstraction > that hides the difference between instances that use a dict as symbol > table, and those that use slots. (And those that use both.) it would be nice to > ignore

[Python-ideas] Re: Add user defined __eq__ to itertools.cycle class

2020-12-30 Thread Steven D'Aprano
On Wed, Dec 30, 2020 at 05:30:52PM -0800, Andres Torres wrote: > As the title suggests, I am requesting an user defined __eq__ method for > the itertools.cycle class. A suggestion for how equivalency might work is > that __eq__ would return True if two cyclers have the same iterable and are > at

[Python-ideas] Add user defined __eq__ to itertools.cycle class

2020-12-30 Thread Andres Torres
As the title suggests, I am requesting an user defined __eq__ method for the itertools.cycle class. A suggestion for how equivalency might work is that __eq__ would return True if two cyclers have the same iterable and are at the same location in their cycle and False in any other condition.

[Python-ideas] On the history and usage of vars [was Re: Re: Unpack operator "**" and Mapping]

2020-12-30 Thread Steven D'Aprano
On Tue, Dec 29, 2020 at 09:02:10AM -0800, Guido van Rossum wrote: > On Tue, Dec 29, 2020 at 8:11 AM Steven D'Aprano wrote: > To the contrary, vars() is something I added to the language for the > benefit of REPL users (like dir()), and other usages look suspect to me. I > find that using

[Python-ideas] Fixing and improving statement caching in sqlite3

2020-12-30 Thread James Oldfield
Hi Python-Ideas, I was browsing the source code to the sqlite3 standard library module (as one does over the Christmas holidays) and was surprised to find that the eviction mechanism for cached prepared statements is fairly broken ... and has been for the last 15 years! This is just from