W
William McBrine
Hi all,
I'm pretty new to Python (a little over a month). I was wondering -- is
something like this:
s = re.compile('whatever')
def t(whatnot):
return s.search(whatnot)
for i in xrange(1000):
print t(something)
significantly faster than something like this:
def t(whatnot):
s = re.compile('whatever')
return s.search(whatnot)
for i in xrange(1000):
result = t(something)
? Or is Python clever enough to see that the value of s will be the same
on every call, and thus only compile it once?
I'm pretty new to Python (a little over a month). I was wondering -- is
something like this:
s = re.compile('whatever')
def t(whatnot):
return s.search(whatnot)
for i in xrange(1000):
print t(something)
significantly faster than something like this:
def t(whatnot):
s = re.compile('whatever')
return s.search(whatnot)
for i in xrange(1000):
result = t(something)
? Or is Python clever enough to see that the value of s will be the same
on every call, and thus only compile it once?