[GRASS-dev] [pygrass] should I use ctypes or cython?

Dear all,

I'm going on with the GSoC, and I'm using ctypes to call the Grass's
function, but I found this comment:

http://stackoverflow.com/a/5686873

(from a cython developer) that it has instilled in me a doubt that
using Cython (http://cython.org/) could make pygrass more
flexible/extensible. From my point of view I prefer ctypes, because it
is already inside grass and because I need to get something running
quickly, but maybe could be more useful for Grass to implement less
code but with a tool that give more flexibility in the future...

What do you think?
Can I go on with my GSoC project using ctypes? should i switch to Cython?

I did some benchmarks to test the speed of pygrass, and it is not too
bad. Below I reported the execution time of add a number to a Raster
map, using r.mapcal module, the RasterRow class (using Rast_get_row,
and Rast_put_row functions), and using the Segmentation library
(segment_get_row and segment_put_row):

r.mapcalc +2; 21.487251 sec/pass
RasterRow +2; 11.181928 sec/pass
RasterSeg +2; 14.730741 sec/pass

Test an if condition:

r.mapcalc if; 14.240596 sec/pass
RasterRow if; 14.753899 sec/pass
RasterSeg if; 19.982334 sec/pass

Test a function:
r.mapcalc sqrt; 16.495872 sec/pass
RasterRow sqrt; 18.591585 sec/pass
RasterSeg sqrt; 22.305732 sec/pass

You may find the code here:

git clone https://code.google.com/p/pygrass/

and you can run the benchmark code with:

python test/benchmark.py

more info on the RasterRow and RasterSegment classes are available here:

http://pygrass.readthedocs.org/en/latest/raster.html

Comments are welcome!

Best regards,

Pietro

Hi Pietro, dear developers,
i think we should stay with ctypes as this is already supported by GRASS.
Also the benchmark results are looking very promising regarding
efficiency to me.

Best regards
Soeren

2012/6/19 Pietro <peter.zamb@gmail.com>:

Dear all,

I'm going on with the GSoC, and I'm using ctypes to call the Grass's
function, but I found this comment:

http://stackoverflow.com/a/5686873

(from a cython developer) that it has instilled in me a doubt that
using Cython (http://cython.org/) could make pygrass more
flexible/extensible. From my point of view I prefer ctypes, because it
is already inside grass and because I need to get something running
quickly, but maybe could be more useful for Grass to implement less
code but with a tool that give more flexibility in the future...

What do you think?
Can I go on with my GSoC project using ctypes? should i switch to Cython?

I did some benchmarks to test the speed of pygrass, and it is not too
bad. Below I reported the execution time of add a number to a Raster
map, using r.mapcal module, the RasterRow class (using Rast_get_row,
and Rast_put_row functions), and using the Segmentation library
(segment_get_row and segment_put_row):

r.mapcalc +2; 21.487251 sec/pass
RasterRow +2; 11.181928 sec/pass
RasterSeg +2; 14.730741 sec/pass

Test an if condition:

r.mapcalc if; 14.240596 sec/pass
RasterRow if; 14.753899 sec/pass
RasterSeg if; 19.982334 sec/pass

Test a function:
r.mapcalc sqrt; 16.495872 sec/pass
RasterRow sqrt; 18.591585 sec/pass
RasterSeg sqrt; 22.305732 sec/pass

You may find the code here:

git clone https://code.google.com/p/pygrass/

and you can run the benchmark code with:

python test/benchmark.py

more info on the RasterRow and RasterSegment classes are available here:

http://pygrass.readthedocs.org/en/latest/raster.html

Comments are welcome!

Best regards,

Pietro
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev