From: John Nagle on 23 Jun 2010 12:10 '_sre.SRE_Pattern' is what "re.compile" returns. Is that a mutable object, with state that changes during the parse, or is it an immutable constant? Can two threads use the same '_sre.SRE_Pattern' at the same time? (I'm writing something to find race conditions in existing code, which is why all these obscure introspection-related questions.) John Nagle
From: Stephen Hansen on 23 Jun 2010 13:27 On Jun 23, 2010, at 9:10 AM, John Nagle <nagle(a)animats.com> wrote: > '_sre.SRE_Pattern' is what "re.compile" returns. > > Is that a mutable object, with state that changes > during the parse, or is it an immutable constant? Can > two threads use the same '_sre.SRE_Pattern' at the same time? Ouch. I hope it is thread safe or I have some problems. But: since compiled regular expressions are automatically cached and used when one throws non compiled expressions into re, ISTM they have to be thread safe. Or we'd have tons of problems. --Stephen via iPad.
From: MRAB on 23 Jun 2010 13:40 John Nagle wrote: > '_sre.SRE_Pattern' is what "re.compile" returns. > > Is that a mutable object, with state that changes > during the parse, or is it an immutable constant? Can > two threads use the same '_sre.SRE_Pattern' at the same time? > > (I'm writing something to find race conditions in existing code, > which is why all these obscure introspection-related questions.) > A compiled pattern instance is immutable and threadsafe. BTW, its methods don't release the GIL, so even if it wasn't threadsafe, it would still be safe. :-)
|
Pages: 1 Prev: Parsing email Next: How to send a non-standard IMAP command? |