[Image-SIG] Multi-threading and PIL
Frédéric
frederic.mantegazza at gbiloba.org
Wed Aug 6 19:17:49 CEST 2008
On mercredi 06 août 2008, Kristofor Amundson wrote:
> I am writing a Python script that is performing lots of pixel-based
> image comparisons and I'm using PIL's PixelAccess object to do this. In
> order to improve my performance I've attempted to multi-thread the
> pixel access using Python's threading module.
>
> My problem is that I see little to no improvement in my performance
> with the threading, even when I process the images on a machine with 8
> CPU's. In fact, it only seems to utilize one CPU. Is this due to the
> GIL? I am wondering if there is a way for me to properly thread this to
> improve my performance.
Due to the global lock in python, threads can't be executed concurrently;
you need to switch to processes. Someone proposed me to use
the 'processing' module:
http://pyprocessing.berlios.de
which will be in standard in future python versions. I didn't make tests
yet, but this section seems interesting, and very simple to use:
http://pyprocessing.berlios.de/doc/pool-objects.html
Hope this help.
--
Frédéric
http://www.gbiloba.org
More information about the Image-SIG
mailing list