On 11 July 2017 at 18:22, Rocky Bernstein <r...@dustyfeet.com> wrote:
> There's too much generalization and abstraction in the discussion at least
> for me. So let me try to make this a little more concrete with real
> examples. First note that, although Python, yes, does "optimize" "if 0:"
> away, as soon as
> you do something as simple as "debug = 0; if debug:" it is confounded. And
> in my own experience I have done this.
>

Typically DEBUG is a global in the module, which means it can be set
from /outside/ the module, so it's not constant as far as the runtime
is concerned.  Within a function it's a bit wacky sure, and is only
kept around for interactive debugging reasons afaict.

Here's a possible type for `self.a` which illustrates why
CSE/Store-Sinking on a STORE_ATTR is not valid for the example
function `foo`.

class A(object):
    def set_b(self, value):
        print value
        self._b = value
    b = property(set_b)

class Example(object):
    def __init__(self):
        self.a = A()

    def foo(self):
        self.a.b = 5
        x = 0
        if x:
            self.a.b = 2
        else:
            return

Example().foo()

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to