Threads, GIL and re.match() performance

Aahz aahz at pythoncraft.com
Wed Jun 25 14:16:40 EDT 2008


In article <slrng64k5c.6qa.mirko-usenet-200806 at dziadzka.de>,
Mirko Dziadzka  <mirko.dziadzka at gmail.com> wrote:
>
>I understand that the C implementation of Python use a global interpreter
>lock to avoid problems, so doing CPU bound tasks in multiple threads
>will not result in better performance on multi-CPU systems.
>
>However, I assumed that calls to (thread safe) C Library functions
>release the global interpreter lock.

Generally speaking that only applies to I/O calls.

>Today I checked the performance of some slow re.match() calls and found,
>that the do not run in parallel on a multi-CPU system. 
>
>1) Is there a reason for this? 
>2) Is the regex library not thread-safe? 
>3) Is it possible, to release the GIL in re.match() to 
>   get more performance?

Theoretically possible, but the usual rule applies: patches welcome
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha



More information about the Python-list mailing list