This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alex
Recipients alex
Date 2009-08-12.21:32:05
SpamBayes Score 0.025523547
Marked as misclassified No
Message-id <1250112728.26.0.437991636315.issue6690@psf.upfronthosting.co.za>
In-reply-to
Content
Just like we turn BUILD_LIST; COMPARE_OP (in) into a LOAD_CONST if all
the members are consts, we can do the same for BUILD_SET, instead
turning it into a LOAD_CONST of a frozenset.  The following is the
bytecode that is current produced for each datastructure.

>>> dis.dis(lambda o: o in (1,2,3))
  1           0 LOAD_FAST                0 (o) 
              3 LOAD_CONST               3 ((1, 2, 3)) 
              6 COMPARE_OP               6 (in) 
              9 RETURN_VALUE         
>>> dis.dis(lambda o: o in [1,2,3])
  1           0 LOAD_FAST                0 (o) 
              3 LOAD_CONST               3 ((1, 2, 3)) 
              6 COMPARE_OP               6 (in) 
              9 RETURN_VALUE         
>>> dis.dis(lambda o: o in {1,2,3})
  1           0 LOAD_FAST                0 (o) 
              3 LOAD_CONST               0 (1) 
              6 LOAD_CONST               1 (2) 
              9 LOAD_CONST               2 (3) 
             12 BUILD_SET                3 
             15 COMPARE_OP               6 (in) 
             18 RETURN_VALUE
History
Date User Action Args
2009-08-12 21:32:08alexsetrecipients: + alex
2009-08-12 21:32:08alexsetmessageid: <1250112728.26.0.437991636315.issue6690@psf.upfronthosting.co.za>
2009-08-12 21:32:06alexlinkissue6690 messages
2009-08-12 21:32:05alexcreate