New submission from Stephen Tu:

Here's a simple patch to optimize away constant boolean 
conjunctions/disjunctions. for example:

def foo():
    if 1 and 0:
        print("hi")

now disassembles into:
  7           0 LOAD_CONST               0 (None) 
              3 RETURN_VALUE 

while I realize more general techniques for achieving this have been proposed 
(ie http://bugs.python.org/issue1346238), this is a very simple, self-contained 
patch.

----------
components: Interpreter Core
files: constcheck.patch
keywords: patch
messages: 186767
nosy: Stephen.Tu
priority: normal
severity: normal
status: open
title: boolop constant checking for if/while
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file29807/constcheck.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17718>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to