Diez B. Roggisch deetsNOSPAM at web.de
Wed Oct 13 14:41:14 CEST 2004

> I think you mean the GIL (Global Interpreter Lock).  PIL is the
> excellent Python Imaging Library.

I certainly did - to less caffeine in system yet...

> Nope.  It doesn't do this.  For access to items such as integers you are
> probably fine, but for things like lists, dictionaries, class
> attributes, etc, you're on your own.  The GIL only ensures that two
> threads won't be executing Python bytecode simultaneously.  It locks the
> Python *interpreter*, not your program or data structures.
> True, you won't get segfaults.  However, you may very well get a
> traceback or mangled data.

I thougth that e.g. list manipulations are bytecodes, thus atomic.
So far, I never ran into serious problems giving me garbage lists or

Nevertheless, I of course used queues and locked access to certain
datastructures when critical sections had to be entered - but in
comparision to java, I never had to ask for a specially thread-hardened
variant of a collection.

> Threading in Python is pretty easy, but certainly not *that* easy.  And
> just to be certain, importing PIL won't help you here either <wink>.

Unless you plan to do some nifty image manipulation work multithreaded....

Diez B. Roggisch

More information about the Python-list mailing list