Re: which one is more efficient

2008-02-11 Thread Steven D'Aprano
On Mon, 11 Feb 2008 10:41:44 -0500, Steve Holden wrote: > If the "type" variable really is a type, of course, then the real > solution is hardly radical: stop using the names of types and start > using the types: [snip example using "type(obj) in (type1, type2)"] But if you're using actual type

Re: which one is more efficient

2008-02-11 Thread Steve Holden
Bruno Desthuilliers wrote: > 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):

Re: which one is more efficient

2008-02-11 Thread bearophileHUGS
Steven D'Aprano: bearophile: > > The new string search done by Effbot is really good :-) > Care to explain what "new string search" you're referring to? Inquiring > minds want to know. I meant this good work you can find in Python 2.5: http://effbot.org/zone/stringlib.htm Bye, bearophile -- http

Re: which one is more efficient

2008-02-11 Thread Bruno Desthuilliers
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 i

Re: which one is more efficient

2008-02-09 Thread Paul Rubin
> 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

Re: which one is more efficient

2008-02-09 Thread Christian Heimes
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 ti

Re: which one is more efficient

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 02:08:15 -0800, bearophileHUGS wrote: > The new string search done by Effbot is really good :-) Care to explain what "new string search" you're referring to? Inquiring minds want to know. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: which one is more efficient

2008-02-09 Thread bearophileHUGS
Michael Spencer: > # perhaps faster > $ python -mtimeit -s"t='D'" "if t in 'DE': pass" > 100 loops, best of 3: 0.204 usec per loop That may be faster indeed, but it gives true if t is "DE" too, and that may be bad. The new string search done by Effbot is really good :-) Bye, bearophile -- ht

Re: which one is more efficient

2008-02-08 Thread Gabriel Genellina
En Fri, 08 Feb 2008 22:45:06 -0200, ki lo <[EMAIL PROTECTED]> escribió: > 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

Re: which one is more efficient

2008-02-08 Thread Michael Spencer
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 t

Re: which one is more efficient

2008-02-08 Thread Gary Herron
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.

which one is more efficient

2008-02-08 Thread ki lo
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. Thanks Kilo -- http://mail.pyt