NEWBIE: ishexdigit revisited
Paul Rubin
http
Tue Dec 30 14:52:01 EST 2003
Kirk Strauser <kirk at strauser.com> writes:
> For production use, I'd factor out the 're' stuff (for performance) and add
> descriptive variable names (it doesn't cost anything) like so:
>
> import re
> hexpattern = re.compile(r'[0123456789abcdefABCDEF]*$')
> ...
> That way, the pattern is only compiled once.
It normally only gets compiled once anyway, then cached. If you
have a really large number of different regexps I guess the cache
can overflow and recompilation happens.
More information about the Python-list
mailing list