Issue 17718: boolop constant checking for if/while (original) (raw)

Issue17718

Created on 2013-04-13 17:17 by Stephen.Tu, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
constcheck.patch Stephen.Tu,2013-04-13 17:17 review
Messages (3)
msg186767 - (view) Author: Stephen Tu (Stephen.Tu) * Date: 2013-04-13 17:17
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.
msg187383 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-04-19 19:10
Thank you for the patch. However, I don't think such "optimizations" are particularly useful.
msg359785 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2020-01-11 06:47
I think this issue should be closed.
History
Date User Action Args
2022-04-11 14:57:44 admin set github: 61918
2020-01-11 06:57:03 benjamin.peterson set status: open -> closedresolution: rejectedstage: resolved
2020-01-11 06:47:52 ZackerySpytz set nosy: + ZackerySpytzmessages: +
2013-04-19 19:10:21 benjamin.peterson set messages: +
2013-04-19 19:02:38 terry.reedy set nosy: + brett.cannon, georg.brandl, ncoghlan, benjamin.peterson
2013-04-13 17:26:22 nedbat set nosy: + nedbat
2013-04-13 17:17:57 Stephen.Tu create