Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Greg Ewing
When testing things like this, as well as testing whether it speeds up your target cases, remember to check that it doesn't slow everything else down due to the increased size of the eval code pushing something out of instruction cache or some such effect. -- Greg

[Python-Dev] PEP 544: Protocols - second round

2017-05-24 Thread Ivan Levkivskyi
Hi all, After collecting suggestions in the previous discussion on python-dev https://mail.python.org/pipermail/python-dev/2017-March/thread.html#147629 and playing with implementation, here is an updated version of PEP 544. -- Ivan A link for those who don't like reading long e-mails:

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Erik
On 24/05/17 21:56, Ben Hoyt wrote: But interesting to know you got not much of a speedup! I think that improvements at the hardware level in terms of parallelizing instruction and data fetching (and branch prediction) in even the cheapest processors these days have largely trivialized the

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Mark Shannon
On 24/05/17 11:07, Ben Hoyt wrote: Hi folks, I was looking at some `dis` output today, and I was wondering if anyone has investigated optimizing Python (slightly) by adding special-case bytecodes for common expressions or statements involving constants? [snip] Hi Ben, What you are

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Ben Hoyt
Interesting -- thanks very much, Erik. Yeah, I wonder if the wordcode will change things too. But interesting to know you got not much of a speedup! Also, the "x is None" and "x is not None" were the opcodes I started out thinking would be helpful, so I'm interested to try those. I'm wondering if

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Erik
Hi Ben, On 24/05/17 19:07, Ben Hoyt wrote: I'm not proposing to do this yet, as I'd need to benchmark to see how much of a gain (if any) it would amount to, but I'm just wondering if there's any previous work on this kind of thing. Or, if not, any other thoughts before I try it? This is

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Xavier Morel
> On 2017-05-24, at 20:26 , Xavier Morel wrote: > >> On 2017-05-24, at 20:07 , Ben Hoyt wrote: >> >> Hi folks, >> >> I was looking at some `dis` output today, and I was wondering if anyone has >> investigated optimizing Python (slightly) by adding

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Xavier Morel
> On 2017-05-24, at 20:07 , Ben Hoyt wrote: > > Hi folks, > > I was looking at some `dis` output today, and I was wondering if anyone has > investigated optimizing Python (slightly) by adding special-case bytecodes > for common expressions or statements involving

Re: [Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Stephane Wirtel via Python-Dev
there is the Peephole for that, it's a small optimizer in the compiler. On 05/24/2017 08:07 PM, Ben Hoyt wrote: Hi folks, I was looking at some `dis` output today, and I was wondering if anyone has investigated optimizing Python (slightly) by adding special-case bytecodes for common

[Python-Dev] Micro-optimizations by adding special-case bytecodes?

2017-05-24 Thread Ben Hoyt
Hi folks, I was looking at some `dis` output today, and I was wondering if anyone has investigated optimizing Python (slightly) by adding special-case bytecodes for common expressions or statements involving constants? For example, I (and, based on a quick grep of the stdlib, many others) write

Re: [Python-Dev] Backport ssl.MemoryBIO on Python 2.7?

2017-05-24 Thread Nick Coghlan
On 24 May 2017 at 14:27, Nathaniel Smith wrote: > On Tue, May 23, 2017 at 8:34 PM, David Wilson wrote: >> On Tue, May 23, 2017 at 06:13:17PM -0700, Cory Benfield wrote: >> >>> There are discussions around Requests unvendoring its dependencies >>> thanks to