GIL in the new glossary

Dave Kuhlman dkuhlman at rexx.com
Fri Oct 3 14:43:20 EDT 2003


Tim Peters wrote:

[snip]

> ... There are 100x more
> third-party extension modules too now, and apart from the handful
> specifically written to increase parallelism, almost all the rest
> surely rely on the GIL too in
> ways the authors remain blissfully unaware of.  Without the GIL,
> *every* extension author has to become an expert in threaded
> programming techniques. With the GIL, most extension authors can
> (and do) ignore the possibility of threads without harm.

What about the implementer of a Python extension who only wants to
be *minimally* or moderately "blissfully unaware" of the GIL.  Is
there a list of n (n < 5) important things to do (or not do) in
order to enable the users of her/his extension obtain as much
parallelism as possible.  

For example, are any of the following good rules to follow?

- Always release the GIL before I/O operations.

- Always release the GIL at the beginning of and re-acquire it at
  the end of any sufficiently long lasting function.

...

And, conversely, is there a list of situations when it would be
dangerous or counter-productive to release the GIL in an
extension?

I took a quick look at the "Extending and Embedding the Python
Interpreter" document, and did not see anything about this.

Dave

-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman
dkuhlman at rexx.com




More information about the Python-list mailing list