[Patches] [ python-Patches-1548082 ] "if x in setliteral" peepholer optimization

SourceForge.net noreply at sourceforge.net
Tue Aug 29 21:08:50 CEST 2006


Patches item #1548082, was opened at 2006-08-28 17:38
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1548082&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Submitted By: Georg Brandl (gbrandl)
>Assigned to: Guido van Rossum (gvanrossum)
>Summary: "if x in setliteral" peepholer optimization

Initial Comment:
Like "for x in tuple_or_list", this patch rewrites "for
x in set" to use a constant frozenset.

----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-08-29 19:08

Message:
Logged In: YES 
user_id=849994

Argh. Like in the py3k mail, I confusedly interchanged "for
x in set" and "if x in set".

if x in [1,2,3] does get special treatment, and optimizing
the "in" test does make sense.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2006-08-29 18:24

Message:
Logged In: YES 
user_id=6380

Um, "for x in [1,2,3]" doesn't get any treatment. What would
be the point of writing "for x in {1,2,3}" anyway?

I'd rather reject this as premature optimization.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1548082&group_id=5470


More information about the Patches mailing list