[Zope-dev] regex vs. re

Michel Pelletier michel@digicool.com
Mon, 28 Jun 1999 09:26:24 -0400


> -----Original Message-----
> From: Phillip J. Eby [mailto:pje@telecommunity.com]
> Sent: Sunday, June 27, 1999 10:04 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] regex vs. re
> 
> 
> Why do DocumentTemplates and ZPublisher use regex instead of 
> re?  Since re
> is thread-safe and regex isn't, wouldn't it make sense to 
> move things in
> the 're' direction?  Or is Python 1.4 still being supported for these
> packages?
> 
> 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.  :) )
> 

Speed is one of the reasons, I'm no expert in this area, but aparently
regex is faster than re.  Also, in may cases we use regex in a
threadsafe fasion.  In the cases where we use regex in a non-threadsafe
fasion, we use t_regex, which is our mutex locked wrapper around regex.

Another reason is time for conversion.  We never got around to
converting to re when it was release, mostly because regex worked and we
didn't want to shift the underlying sands.

If you want to try and make an re pure version of ZPublisher, let us
know how it goes.  If it's as fast and cleaner, we'll probably use it
(after extensive testing, of course ;).

The Let tag rules!

-Michel

> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://www.zope.org/mailman/listinfo/zope-dev
> 
> (For non-developer, user-level issues, use the companion list,
> zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
>