Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
On Mar, Feb 10, 2009 10:20PM, Raymond Hettinger wrote: > [Cesare Di Mauro] >> I'm playing with the virtual machine and I have some ideas about >> possibile >> optimizations that could be applyed. But I need to verify them, so >> understanding what is possible and what is not, is a primary goal for

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Raymond Hettinger
[Cesare Di Mauro] I'm playing with the virtual machine and I have some ideas about possibile optimizations that could be applyed. But I need to verify them, so understanding what is possible and what is not, is a primary goal for me. The best way to understand what is possible is to disassemble

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Dino Viehland
we're assigning ids differently :) -Original Message- From: Cesare Di Mauro [mailto:cesare.dima...@a-tono.com] Sent: Tuesday, February 10, 2009 1:12 PM To: Dino Viehland Cc: Daniel Stutzbach; cesare.dima...@a-tono.com; Python-Dev Subject: RE: [Python-Dev] Expression optimizations It&#x

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
org > [mailto:python-dev-bounces+dinov=microsoft@python.org] On Behalf Of > Daniel Stutzbach > Sent: Tuesday, February 10, 2009 12:43 PM > To: cesare.dima...@a-tono.com > Cc: Python-Dev > Subject: Re: [Python-Dev] Expression optimizations > > On Tue, Feb 10, 2009 at 2:3

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Dino Viehland
@python.org] On Behalf Of Daniel Stutzbach Sent: Tuesday, February 10, 2009 12:43 PM To: cesare.dima...@a-tono.com Cc: Python-Dev Subject: Re: [Python-Dev] Expression optimizations On Tue, Feb 10, 2009 at 2:36 PM, Cesare Di Mauro wrote: OK, so I can make assumptions only for built-in types.

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
On Mar, Feb 10, 2009 09:42PM, Daniel Stutzbach wrote: > On Tue, Feb 10, 2009 at 2:36 PM, Cesare Di Mauro > wrote: > >> OK, so I can make assumptions only for built-in types. >> > > Yes, but even there you have to be careful of odd corner-cases, such as: > nan = float('nan') nan < nan > Fa

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
On Mar, Feb 10, 2009 08:15 PM, Raymond Hettinger wrote: > > - Original Message - > From: "Cesare Di Mauro" > To: "Python-Dev" > Sent: Tuesday, February 10, 2009 8:24 AM > Subject: [Python-Dev] Expression optimizations > > >> In

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
On Mar, Feb 10, 2009 06:24 PM, Daniel Stutzbach wrote: > On Tue, Feb 10, 2009 at 11:16 AM, Steve Holden > wrote: > >> That's true, but the same *could* be said about the existing >> optimizations for objects that define their own __contains__. >> > > No, because there isn't a __not_contains__, so

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Daniel Stutzbach
On Tue, Feb 10, 2009 at 2:36 PM, Cesare Di Mauro wrote: > OK, so I can make assumptions only for built-in types. > Yes, but even there you have to be careful of odd corner-cases, such as: >>> nan = float('nan') >>> nan < nan False >>> nan >= nan False -- Daniel Stutzbach, Ph.D. President, Stutz

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
On Mar, Feb 10, 2009 at 05:38 PM, Daniel Stutzbach wrote: > On Tue, Feb 10, 2009 at 10:24 AM, Cesare Di Mauro > > wrote: > >> Could it be applyable to other operations as well? So, if I wrote: >> c = not(a < b) >> the compiler and/or peephole optimizer can generate bytecodes >> instructions >> whi

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Raymond Hettinger
- Original Message - From: "Cesare Di Mauro" To: "Python-Dev" Sent: Tuesday, February 10, 2009 8:24 AM Subject: [Python-Dev] Expression optimizations In peephole.c I noticed some expression optimizations: /* not a is b --> a is not b not a in b -->

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Antoine Pitrou
Steve Holden holdenweb.com> writes: > > That's true, but the same *could* be said about the existing > optimizations for objects that define their own __contains__. No, because there is no such thing as __not_contains__. Regards Antoine. ___ Python

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Steve Holden
Daniel Stutzbach wrote: > On Tue, Feb 10, 2009 at 11:16 AM, Steve Holden > wrote: > > That's true, but the same *could* be said about the existing > optimizations for objects that define their own __contains__. > > > No, because there isn't a __not_contains__

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Daniel Stutzbach
On Tue, Feb 10, 2009 at 11:16 AM, Steve Holden wrote: > That's true, but the same *could* be said about the existing > optimizations for objects that define their own __contains__. > No, because there isn't a __not_contains__, so you cannot define the inverse operation differently. "not a in b"

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Steve Holden
Daniel Stutzbach wrote: > On Tue, Feb 10, 2009 at 10:24 AM, Cesare Di Mauro > mailto:cesare.dima...@a-tono.com>> wrote: > > Could it be applyable to other operations as well? So, if I wrote: > c = not(a < b) > the compiler and/or peephole optimizer can generate bytecodes > instruc

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Antoine Pitrou
Cesare Di Mauro a-tono.com> writes: > Could it be applyable to other operations as well? So, if I wrote: > > c = not(a < b) > > the compiler and/or peephole optimizer can generate bytecodes instructions which, instead, execute the > following operation: > > c = a >= b > > Is it right? No,

Re: [Python-Dev] Expression optimizations

2009-02-10 Thread Daniel Stutzbach
On Tue, Feb 10, 2009 at 10:24 AM, Cesare Di Mauro wrote: > Could it be applyable to other operations as well? So, if I wrote: > c = not(a < b) > the compiler and/or peephole optimizer can generate bytecodes instructions > which, instead, execute the following operation: > c = a >= b > Those tw

[Python-Dev] Expression optimizations

2009-02-10 Thread Cesare Di Mauro
In peephole.c I noticed some expression optimizations: /* not a is b --> a is not b not a in b --> a not in b not a is not b --> a is b not a not in b --> a