Iterating across a filtered list
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Mar 13 19:03:03 EDT 2007
En Tue, 13 Mar 2007 19:12:12 -0300, Arnaud Delobelle
<arnodel at googlemail.com> escribió:
>> py> import re
>> py> x = re.compile("ijk")
>> py> y = re.compile("ijk")
>> py> x is y
>> True
>>
>> Both, separate calls, returned identical results. You can show the
>> cache:
>
> OK I didn't realise this. But even so each time there is the cost of
> looking up the regexp string in the cache dictionary.
Sure, it's much better to create the regex only once. Just to note that
calling re.compile is not soooooooo bad as it could.
--
Gabriel Genellina
More information about the Python-list
mailing list