Message54932
Logged In: YES
user_id=80475
I looked at this when constant folding was first introduced
and it did not seem worth doing because 1) it would be
somewhat complicated to implement (counting each time a
constant is used and renumbering all constant references
once a deletion occurs), 2) it would be hard to maintain, 3)
it would slow-down compilation, and 4) the potential benefit
is microscopic (saving a few bytes but not improving
execution speed).
Here's an example of the difficulty:
>>> def f():
x = 3
y = 3 + 4
return x + y
>>> f.func_code.co_consts
(None, 3, 4, 7)
The constant folding for 3+4 introduces the 7 but cannot
easily know that the 3 is used elsewhere while the 4 is not.
Am reclassifying this as a feature request for a trivial
space optimization (there is no bug, the peepholer is
functioning as designed). This suggestion could be
implemented but (IMO) is not worth it.
|
|
Date |
User |
Action |
Args |
2007-08-23 16:12:17 | admin | link | issue1589074 messages |
2007-08-23 16:12:17 | admin | create | |
|