How best to write this if-else?...threads

Harry George hgg9140 at cola.ca.boeing.com
Tue Apr 24 09:27:00 EDT 2001


Yes, perl itself is in trouble when "match" meets threads.  That is
why my pyperl module allows a separate PyPerl object instantiation for
each thread -- so the PREMATCH et al. are protected.  Globals are not
used.

I don't see why re can't similarly provide a thread-safe unit for the
"globals".


"Mike C. Fletcher" <mcfletch at home.com> writes:

> Hmm, what does Perl do when there's multiple threads using the same re
> concurrently?  I think that's the major reason behind the matchobject
> approach that arrived with the re module (the older regex module uses a
> pattern similar to what you've described).
> 
> Enjoy,
> Mike
> 
> -----Original Message-----
> From: Harry George [mailto:hgg9140 at cola.ca.boeing.com]
> Sent: Monday, April 23, 2001 09:46
> To: python-list at python.org
> Cc: nobody
> Subject: Re: How best to write this if-else?
> ...
> This allows the perlish idiom:
> 
> if p.m(regexpr_here,data_string_here):
>     prematch=p.PREMATCH
>     match=p.MATCH
>     postmatch=p.POSTMATCH
>     group1=p.S1    # S = $
>     ....
> ...
> 
> 

-- 
Harry George                E-mail:  harry.g.george at boeing.com
The Boeing Company          Renton:  (425) 237-6915
P. O. Box 3707  02-CA       Everett: (425) 266-3868
Seattle, WA 98124-2207      Page:    (425) 631-8803  



More information about the Python-list mailing list