classification
Title: Remove unused constants from optimized code objects
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 2.6
process
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 2008-06-12 22:08 by rhettinger. This issue is now closed.

Files
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 
constants.
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 
time.  

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.
History
Date User Action Args
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