On Sun, 6 Feb 2005 10:49:05 -0600, Skip Montanaro [EMAIL PROTECTED] wrote:
Wouldn't it be better to have the peephole optimizer recognize the throwaway
nature of lists in these contexts:
for elt in [1, 2, 4, 8, 16]:
...
if foo in [list, tuple]:
...
(anywhere
[Neal]
I think I implemented this once. I'll try to see if I can find a
patch. It wasn't too difficult, but I'm not sure if the patch was
clean.
If the opportunity arises, another worthwhile peepholer buildout would
be to recognize if-elif chains that can be transformed to a single
lookup
Raymond [Skip]
If lists are conceptually like vectors or arrays in other languages
and tuples are like C structs or Pascal records, then by converting
from list to tuple form you've somehow muddied the data structure
water just to take advantage of tuples' immutability.