On Wed, May 13, 2009 at 2:57 PM, Dag Sverre Seljebotn <
[email protected]> wrote:

> Dag Sverre Seljebotn wrote:
>
>
> Note that one could implement this in "shadow module" mode as well. I.e.
>
> @cython.locals(arr=cython.int[:])
> def f(arr):
>     return arr * arr + 2
>
> could be made to work in pure Python mode by coercing the argument to an
> appropriate NumPy subclass emulating the explicit buffers.
>
> So I think it is primarily about what kind of syntax it is natural to
> work with etc; the one "transparently" optimizing some parts of what one
> is used to writing in Python, or the one shouting "syntax error"
> whenever you do something which is not an optimized, fast operation.
>
> I find I now (after nearly a year) wish I had gone for the latter
> instead :-) as users are still caught by surprise that e.g. "arr[2][3]"
> isn't as fast as "arr[2,3]", but there's no compiler complaints, and so on.
>
>
Why not give warning when certain constructors are likely slower than
expected? At least when running with something like -Wall.

Also to me the strength of cython is that I can take a python function and
add only minimal information (a few cdefs for variables) and get a lot of
speedup. I wouldn't start a project with cython.Iif  know from the beginning
it is to slow in python, then I do that directly in C/C+.

The problem is that cython does not help really for code heavily using numpy
arrays without loops. So it would be great to be able to define a numpy
array as a blitz/eigen array and some plugin conversion rules convert the
calls. Sure it would prohibit to use subclasses. But to me that would be
similar to changing an Python variable to a cython int. There one also has
to make sure that e.g. there is no overflow.

A general way to work on buffers would probably be nice, but it would not
help so much in being easily able to speed up numpy code with cython, if it
is not using the numpy syntax.

Roland
-- 
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to