[Cython] aritmetic with arrays in Cython

Ian Henriksen insertinterestingnamehere at gmail.com
Fri Oct 24 15:18:19 CEST 2014


On Fri, Oct 24, 2014 at 2:36 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:

> Ian Henriksen schrieb am 09.08.2014 um 00:15:
> > On Fri, Aug 8, 2014 at 3:09 PM, Ian Henriksen wrote:
> >> On Fri, Aug 8, 2014 at 12:02 PM, Julian Taylor wrote:
> >> Stefan, thanks for the direction. I think I know how to proceed now.
> It'll
> >> probably take me some time to learn how to do all this, but I'll start
> >> reading/working on it now.
> >>
> >> Julian, from a dependency standpoint I'd really prefer to use numpy. As
> >> near as I can tell, the people most likely to use this feature already
> use
> >> numpy. That would also remove the C++ dependency for this. I think the
> main
> >> reason for using eigen is that it will be easy to interface with and
> will
> >> eliminate temporaries automatically. In the long term, it could be good
> to
> >> offer multiple backends for these sorts of operations. Numpy would be a
> >> primary candidate for something like that. I'll spend some time working
> >> with numpy's ufunc api to see if I can figure out a good way to use that
> >> instead.
> >
> > Maybe I should clarify a little about why eigen is a good place to start.
> > According to http://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html it
> > already takes care of things like the elimination of temporary variables
> > and common subexpression reduction at compile time. This should make it
> > possible to compile array expressions in Cython without having to
> > re-implement those sorts of optimizations. Ideally we would just have to
> > map memory view operations to corresponding equivalents from eigen. It's
> > not yet clear to me how to do things with arbitrary-dimensional arrays or
> > broadcasting, but, given some more time, a solution may present itself.
>
> Did anything come out of this yet?
>
> Stefan
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>

Unfortunately, nothing directly on an syntax tree transformer.
I've been working on a related scipy pull request to expose
their blas and lapack wrappers to cython. There are a few things left to add
before it is merged there, but it should be a helpful start to making linear
algebra operations more available in cython.
See https://github.com/scipy/scipy/pull/4021. I'm a little overwhelmed this
semester, so that is coming slower than I'd like, but I'm hoping to finish
in
the next two weeks or so.

>From there, I've done a bit more reading, and it seems the best
approach is to work on the wrappers for continuum's dynd array library.
It already has a design similar to numpy and it's bindings are already
written in cython. See https://github.com/ContinuumIO/libdynd and
https://github.com/ContinuumIO/dynd-python, particularly
https://github.com/ContinuumIO/libdynd/blob/master/docs/DESIGN.txt
Getting n-dimensional array arithmetic should just be a matter of
exposing their cython bindings to external packages properly.
They don't have the buffer interface from pep 3118 set up yet though,
so there is more work to be done there. I'd definitely welcome your
input on that plan, or on anything I've done thus far.

Thank you for your ideas and feedback.

-Ian Henriksen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20141024/94c2b510/attachment.html>


More information about the cython-devel mailing list