[Zope-dev] regex vs. re

Jim Fulton jim@digicool.com
Mon, 28 Jun 1999 09:43:52 -0400


"Phillip J. Eby" wrote:
> 
> Why do DocumentTemplates and ZPublisher use regex instead of re? 

Two reasons:

  1. Speed: regex is substantially faster than re

  2. Intertia: we expect to change eventually, especially
     after re is optimized.

> Since re
> is thread-safe and regex isn't, wouldn't it make sense to move things in
> the 're' direction? 

regex can be used in thread-safe ways.  AFAIK, all of the uses in 
DocumentTemplate and ZPublisher are thread safe.

We are going through the rest of the Zope code to check for
non-thread-safe uses of regex, regsub, and mutable "static"
variables (e.g. global variables and function defaults).

> Or is Python 1.4 still being supported for these
> packages?

No.
 
> One reason I ask is that I'm about to begin using regular expression in
> ZPublished code, and I'm wondering whether there's some special reason I
> should use regex instead of re.  (Aside from the fact that it would mean
> not loading two different regular expression libraries, of course.  :) )

I don't have a strong opinion on this.  Switching from regex to re is 
not very high on our priority list.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.