Paul Rubin a écrit : >> ki lo wrote: >>> I have type variable which may have been set to 'D' or 'E' >>> >>> Now, which one of following statements are more efficient >>> >>> if type =='D' or type == 'E': >>> >>> or >>> >>> if re.search("D|E", type): >>> >>> Please let me know because the function is going to called 10s of millions >>> of times. >> For maximum efficiency you have to use a set. > > if type in 'DE': ... > > might be faster.
It might also be wrong if there's a possibility that type=='DE' : >>> "DE" in "DE" True -- http://mail.python.org/mailman/listinfo/python-list