which one is more efficient
Paul Rubin
http
Sun Feb 10 01:13:06 EST 2008
> 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. Really the only way to know is make actual
measurements.
More information about the Python-list
mailing list