[New-bugs-announce] [issue7682] Optimisation of if with constant expression

Sylvain Defresne report at bugs.python.org
Tue Jan 12 13:22:03 CET 2010


New submission from Sylvain Defresne <sdefresne at gmail.com>:

Python compiler detect some constant expression used in if / while statement and evaluate them at compilation. However, it does not perform some simple optimisation (evaluating not unary expression or checking if and or or expression are constant because of the first expression).

The attached patch allow Python to detect some more constant expression, and to optimise test like the following:

   if __debug__ and x:
       pass

   if not __debug__:
       pass

----------
components: Interpreter Core
files: compile.diff
keywords: patch
messages: 97631
nosy: sdefresne
severity: normal
status: open
title: Optimisation of if with constant expression
type: performance
versions: Python 3.2
Added file: http://bugs.python.org/file15836/compile.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7682>
_______________________________________


More information about the New-bugs-announce mailing list