Is re thread-safe?

Michael Hudson mwh at
Thu Dec 25 12:40:36 CET 2003

Benjamin Han <bhan at> writes:

> Just want to make sure before I start to change my code in major way - it'd
> be nice to do regex matching in parallel.

Um.  I doubt the sre engine releases the GIL during matching -- might
be wrong -- but unless you're on a multiprocessor I'm not quite sure
what "in parallel" would mean.

I don't think you'll encounter misbehaviour from using re in multiple


  ... with these conditions cam the realisation that ... nothing
  turned a perfectly normal healthy individual into a great political
  or military leader better than irreversible brain damage.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11

More information about the Python-list mailing list