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.

Title: Remove unused constants from optimized code objects
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: belopolsky, rhettinger
Priority: normal Keywords: patch

Created on 2008-03-26 14:47 by belopolsky, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
compress-consts.diff belopolsky, 2008-03-26 14:47 Patch against revision 61948
compress-consts-1.diff belopolsky, 2008-03-26 15:31 Patch against revision 61948
Messages (3)
msg64558 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-26 14:47
When peephole optimizer folds multiple constants into one, the old 
constants remain in co_consts.  Attached patch removes such unused 
msg64561 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-26 15:31
I've noticed that the original patch does not handle the error condition 
from failed consts resize correctly.  Please see compress-consts-1.diff 
for a fix.
msg68101 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-06-12 22:08
The issue with unused constants is an artifact of the peepholer running 
after the bytecode generation phase.  When constant folding was 
written, I intentionally left-out a step to remove unused constants 
because of the code complexity, the fragility of the process, because 
the benefits were inconsequential, and because it added to compilation 

It would be better to wait for the AST optimizer to replace the 
peepholer.  AST optimizations are upstream from bytecode generation, so 
the unused constant issue simply disappears.
Date User Action Args
2022-04-11 14:56:32adminsetgithub: 46745
2008-06-12 22:08:50rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg68101
2008-03-26 15:31:22belopolskysetfiles: + compress-consts-1.diff
messages: + msg64561
2008-03-26 15:06:16rhettingersetassignee: rhettinger
nosy: + rhettinger
2008-03-26 14:47:35belopolskycreate