Kay Schluehr wrote:
Actually it is simply wrong in the mentioned case and here is the
proof:

def foo():
    return 2+2

import dis
dis.dis(foo)

  2           0 LOAD_CONST               2 (4)
              3 RETURN_VALUE

OO is a heuristic method used to understand the semantics of a
programming language. It can also inspire language design but as
you've rightly said: jugde yourself and see how far you get with it.

It's not wrong. You have found a simple optimization. Lot's of compilers for lots of languages optimize code by code folding.

Python's peephole optimizer replaces code like 2+2 with 4.

Christian

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to