[Image-SIG] Comparison of PIL and GD speed for setting pixels through python
John Barratt
jb at langarson.com.au
Fri Feb 2 07:32:57 CET 2007
Hi,
I've had a need to do some optimisation of some low level pixel setting
code, and have as such done some tests of different ways of doing this
using PIL and alternatively with gd via ctypes.
Ctypes provides a fairly easy way to interface to gd, and allows you to
easily use small sections of optimising C code. A summary of the
results is below, but basically using ctyles/GD/c is about 20 or so
times faster than PIL and the new Image.load, and over 200 times faster
than using PIL's ImageDraw.point method.
Method Time (s) Times slower than fastest
+-----+ +-------+ +------------------------+
ctypes, c, GD 0.00181 1.0
PIL - 'load' 0.03965 21.9
ctypes, GD 0.18710 103.5
PIL - 'point' 0.45009 248.9
A full writeup of this can be found here :
http://www.langarson.com.au/blog/?p=10
I hope this is of use, and I look forward to comments, particularly on
other ways of doing this with PIL & C, which there undoubtedly are.
Cheers,
JB.
--
John Barratt
www.langarson.com.au - Python, Zope, GIS, Weather.
More information about the Image-SIG
mailing list