[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Wes Turner
pyrsistent.PMap and PRecord may be worth a look: https://pyrsistent.readthedocs.io/en/latest/api.html#pyrsistent.PMap : > Persistent map/dict. Tries to follow the same naming conventions as the built in dict where feasible. > > Do not instantiate directly, instead use the factory functions m()

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Yury Selivanov
On Wed, Jul 22, 2020 at 9:25 PM Marco Sulla wrote: <...> > On Wed, 22 Jul 2020 at 18:26, Guido van Rossum wrote: >> >> Did you study PEP 416 (frozendict) and PEP 603 (frozenmap)? > > > Yes. About frozenmap, at the very start I added to the benchmarks also > immutables.Map, but I removed it when

[Python-ideas] Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Marco Sulla
On Wed, 22 Jul 2020 at 15:35, Antoine Pitrou wrote: > The deltas also look small for a micro-benchmark. I certainly don't > think this is a sufficient reason to add a new datatype to Python. > I think some of the optimizations can be experimented with dict itself. Deltas seem to be small,

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Rob Cliffe via Python-ideas
On 22/07/2020 22:22, Chris Angelico wrote: On Thu, Jul 23, 2020 at 7:06 AM João Matos wrote: Hello, Why not just use Raymond's suggestion nobreak as a replacement of the else in loops and deprecate the else in Python 4? There is at least a precedent when not equal <> was deprecated in

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread João Matos
Hello, Maybe I didn't explain it correctly. What I meant was to do exactly the same that happened with <>/!=. That is, add nobreak in Py3 (allowing the use of both else/nobreak) and only deprecate else in Py4. João Matos On 22/07/2020 22:22, Chris Angelico wrote: On Thu, Jul 23, 2020 at

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Chris Angelico
On Thu, Jul 23, 2020 at 7:06 AM João Matos wrote: > > Hello, > > Why not just use Raymond's suggestion nobreak as a replacement of the else in > loops and deprecate the else in Python 4? > There is at least a precedent when not equal <> was deprecated in favor of != > from Py2 to Py3. > We

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread João Matos
Hello, Why not just use Raymond's suggestion nobreak as a replacement of the else in loops and deprecate the else in Python 4? There is at least a precedent when not equal <> was deprecated in favor of != from Py2 to Py3. We could do the same with else/nobreak between Py3 and Py4. João Matos

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Guido van Rossum
Did you study PEP 416 (frozendict) and PEP 603 (frozenmap)? -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* ___

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Mathew Elman
On Wed, 22 Jul 2020 at 13:45, Paul Moore wrote: > On Wed, 22 Jul 2020 at 13:18, Mathew Elman wrote: > >> Ones that retain else on loops are bad because > >> they end up providing two (typically equally confusing) ways of doing > >> things. > > > > I don't think this is the case. I agree that

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Antoine Pitrou
On Wed, 22 Jul 2020 15:06:59 +0200 Marco Sulla wrote: > What I'm doing on the contrary is a micro benchmark: I would confront if an > algorithm is faster in a particular case (immutable dict). > > I runned the benchmarks many times, and even if the absolute values are not > stable, the delta

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Marco Sulla
The article is really interesting. Anyway, I think pyperf was developed mainly for macro benchmarks. Its goal is to make different benchmarks on different machines or in different times comparable. What I'm doing on the contrary is a micro benchmark: I would confront if an algorithm is faster in a

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Paul Moore
On Wed, 22 Jul 2020 at 13:18, Mathew Elman wrote: >> Ones that retain else on loops are bad because >> they end up providing two (typically equally confusing) ways of doing >> things. > > I don't think this is the case. I agree that adding an alternative to `else` > just to have an alternative

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Mathew Elman
On Wed, 22 Jul 2020 at 12:24, Paul Moore wrote: > On Wed, 22 Jul 2020 at 10:54, Stestagg wrote: > > > > I'm (weakly) +1 for the concept of for..else being confusing, weird, and > somehow not quite suitable/useful for many use-cases where it feels like it > should. > > > > I'm -1 for each of the

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Paul Sokolovsky
Hello, On Wed, 22 Jul 2020 20:00:29 +1000 Steven D'Aprano wrote: [] > > > py> for x in [1,2]: > > > ... print("inside loop") > > > ... else: > > > ... print("elif never looped") > > > ... > > > inside loop > > > inside loop > > > elif never looped >

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Paul Moore
On Wed, 22 Jul 2020 at 10:54, Stestagg wrote: > > I'm (weakly) +1 for the concept of for..else being confusing, weird, and > somehow not quite suitable/useful for many use-cases where it feels like it > should. > > I'm -1 for each of the suggested improvements that I've understood so far. > > I

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Steven D'Aprano
On Tue, Jul 21, 2020 at 05:48:35PM -0700, Christopher Barker wrote: > for something in some_iterable: > some_stuff_with_maybe_a_break > else: # if not break: > something_more > > and no changes needed to Python! > > I may actually start doing that myself ... I always do that, not

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Steven D'Aprano
On Wed, Jul 22, 2020 at 06:14:39AM +0300, Paul Sokolovsky wrote: > Hello, > > On Wed, 22 Jul 2020 09:45:31 +1000 > Steven D'Aprano wrote: > > > On Tue, Jul 21, 2020 at 10:07:47PM +0100, Barry wrote: > > > > > 1. Because that not what else mean today. Its elif never looped. > > > > > >

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Stestagg
I'm (weakly) +1 for the concept of for..else being confusing, weird, and somehow not quite suitable/useful for many use-cases where it feels like it should. I'm -1 for each of the suggested improvements that I've understood so far. I agree that the suggested 'ban' on changes in this area is

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Mathew Elman
On Wed, 22 Jul 2020 at 04:47, Paul Sokolovsky wrote: > Hello, > > On Tue, 21 Jul 2020 17:48:35 -0700 > Christopher Barker wrote: > > > how about: > > > > for something in some_iterable: > > some_stuff_with_maybe_a_break > > else if not break: > > something_more > > > > No new keywords

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Inada Naoki
On Wed, Jul 22, 2020 at 4:29 PM Marco Sulla wrote: > > Furthermore, it seems that pyperf has not disabled ASLR. After `sudo python > -m pyperf system tune`, ASRL continues to be in "Full randomization" mode. > You are right. pyperf doesn't disable ASLR, because code performance is changed by

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Marco Sulla
Well, I tried it. The result is interesting: https://github.com/Marco-Sulla/cpython/blob/master/frozendict/test/bench_pyperf.txt The main speedups are confirmed, and maybe also accentuated. But some others are diminished or vanished. The most notable is pickle.dumps(). I have to say I did not

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Christopher Barker
> I find the need for that regularly. And I use the obvious syntax which > everyone else uses: > > if not seq: > print("This page is intentionally left blank") > else: > for i in seq: > ... Not so easy for an iterator though. I’m more likely to do something like this: Page =

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Chris Angelico
On Wed, Jul 22, 2020 at 1:15 PM Paul Sokolovsky wrote: > > Hello, > > On Wed, 22 Jul 2020 09:45:31 +1000 > Steven D'Aprano wrote: > > > On Tue, Jul 21, 2020 at 10:07:47PM +0100, Barry wrote: > > > > > 1. Because that not what else mean today. Its elif never looped. > > > > > > py> for x in