This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Optimize out __debug__ at the AST level
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: methane, pitrou, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-12-19 14:11 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4925 merged serhiy.storchaka, 2017-12-19 14:17
Messages (2)
msg308643 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-19 14:11
__debug__ is substituted by the constant value at the code generation stage (see issue27169). This prevents it from participating in constant folding at the AST level. The proposed patch moves this optimization to the AST level. This will lead to optimizing "if not __debug__" and will allow to add more optimizations at the AST level (like optimizing expressions "a if __debug__ else b" and "__debug__ and a").
msg309035 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-25 10:47
New changeset 3dfbaf51f0d90646e0414ddbd3b513ee8e5ffe9b by Serhiy Storchaka in branch 'master':
bpo-32372: Move __debug__ optimization to the AST level. (#4925)
https://github.com/python/cpython/commit/3dfbaf51f0d90646e0414ddbd3b513ee8e5ffe9b
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76553
2017-12-25 10:48:57serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-25 10:47:57serhiy.storchakasetmessages: + msg309035
2017-12-19 14:17:18serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request4819
2017-12-19 14:11:45serhiy.storchakacreate