Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-05 Thread John Barratt
Well after some digging through the PIL source code after the prompting from Douglas, and some tinkering with the python C interface, I have implemented a C based version of the core pixel setting loop using PIL objects. I have also added 'reference' versions using plain python, setting an

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-05 Thread Christopher Barker
John Barratt wrote: I haven't tried it, but did originally think of adding it to the list of things tested. Given this specific example though, where the idea is that a specific method or piece of code is needed to be run for every pixel (not that it actually is in this abstract example),

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-05 Thread John Barratt
Hi Chris, Christopher Barker wrote: I think where PIL numpy would excel is where you have a cases of a number of images with calculations required that could be easily represented as array operations. The examples I am thinking of don't lend themselves to this sort of solution. Also

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-05 Thread John Barratt
Hi Douglas, Douglas Bagnall wrote: um.. cache locality? With GD you have for (u=0; ux; u++) { for (v=0; vy; v++) { d[v][u] = colour; } } which goes through every row for each column, jumping back and forth in memory. You need to switch the order of the loops, like

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-04 Thread John Barratt
Christopher Barker wrote: John Barratt wrote: 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. Have you tried using PIL + numpy -- you can

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-04 Thread John Barratt
With prompting from Chris, and a little further work in gd, I have updated this comparison further, adding a further gd/ctypes test, this time setting pixel values using the raw pixel data, as well as the start of a test for a numpy/PIL option. Unfortunately it doesn't fully work, at least

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-04 Thread Douglas Bagnall
hi John, Method Time (s)Times slower than fastest +-+ +---+ ++ ctypes,c,GD raw 0.00082 1.0 ctypes,c,GD 0.00177 2.2 PIL - 'load'0.03226 39.4 ctypes, GD 0.14428 176.4 PIL, numpy *

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-04 Thread John Barratt
Hi Douglas, Douglas Bagnall wrote: Method Time (s)Times slower than fastest +-+ +---+ ++ ctypes,c,GD raw 0.00082 1.0 ctypes,c,GD 0.00177 2.2 PIL - 'load'0.03226 39.4 ctypes, GD 0.14428