Re: Pull request: morphology fix
On 10/19/2011 08:44 PM, St�fan van der Walt wrote:
On Wed, Oct 19, 2011 at 9:57 AM, Ralf Gommers
wrote: Does anyone here have experience with such approaches?
scipy.interpolate has Cython code with simple Mako templating, look at interpnd.pyx and generate_interpnd.py. If it's flexible enough for your needs then it'll be a lot more pleasant than using C++. This definitely gets us some way. We can modify our _build.cython call to first run the template engine on any .tpyx files.
But how should we dispatch to different functions, based on dtype? Let's say we have support for int16, uint16 and double in our algorithm, so via templating we'll get
myfunc_int16 myfunc_uint16 myfunc_double
for a single input argument (which is the most common case). We can then define a dispatch call such as
dtype_call('myfunc', img.dtype)
which calls the appropriate function. Does this sound about right? Sounds sensible. Doing the overloading "by hand" looks a bit ugly but it seems cython does not do overloading of cython functions: http://wiki.cython.org/enhancements/overloading Overloaded C++ functions on the other hand seem to be no problem http://wiki.cython.org/WrappingCPlusPlus.
On Wed, Oct 19, 2011 at 11:56 AM, Andreas Mueller
scipy.interpolate has Cython code with simple Mako templating, look at interpnd.pyx and generate_interpnd.py. If it's flexible enough for your needs then it'll be a lot more pleasant than using C++.
Brian also took this conversation over to the scikit-learn list, where it came out that Tempita is quite popular. I've used it before, and it's lightweight and can be included as a single .py in our repository. We now need someone to modify the _build.cython script to convert .pyx.in files to .pyx files before building, much like in this script: https://raw.github.com/dagss/private-scipy-refactor/cythonize/cythonize.py Any takers? Stéfan
participants (2)
-
Andreas Mueller
-
Stéfan van der Walt