[New-bugs-announce] [issue17718] boolop constant checking for if/while
Stephen Tu
report at bugs.python.org
Sat Apr 13 19:17:57 CEST 2013
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 <report at bugs.python.org>
<http://bugs.python.org/issue17718>
_______________________________________
More information about the New-bugs-announce
mailing list