Threads, GIL and re.match() performance

Mirko Dziadzka mirko.dziadzka at gmail.com
Wed Jun 25 10:05:32 EDT 2008


Hi all

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.

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?

I'm using Python 2.5

Thanks for your help

    Mirko


-- 
"I've found that people who are great at something are not so much
convinced of their own greatness as mystified at why everyone else seems
so incompetent."
					Paul Graham in "Great Hackers"



More information about the Python-list mailing list