[Python-Dev] list of constants -> tuple of constants
Neal Norwitz
nnorwitz at gmail.com
Sun Feb 6 19:05:46 CET 2005
On Sun, 6 Feb 2005 10:49:05 -0600, Skip Montanaro <skip at pobox.com> 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 a list of constants immediately follows the "in" or "not in"
> keywords) and convert them into constants? The cases you converted all
> matched that usage.
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.
Neal
More information about the Python-Dev
mailing list