[Cython] aritmetic with arrays in Cython

Ian Henriksen insertinterestingnamehere at gmail.com
Thu Aug 7 01:30:21 CEST 2014


Message: 3
Date: Tue, 05 Aug 2014 21:38:38 +0200
From: Julian Taylor <jtaylor.debian at googlemail.com>
To: Core developer mailing list of the Cython compiler
        <cython-devel at python.org>
Subject: Re: [Cython] aritmetic with arrays in Cython
Message-ID: <53E132BE.3070207 at googlemail.com>
Content-Type: text/plain; charset="windows-1252"

>On 04.08.2014 21:11, Ian Henriksen wrote:
>> Hi all,
>> I noticed that some time ago there was a pull request
>> (https://github.com/cython/cython/pull/144) open that was trying to
>> implement basic arithmetic operations with arrays. This seems to have
>> also been proposed in CEP 518
>> (https://github.com/cython/cython/wiki/enhancements-simd). What is the
>> status on this?
>>
>> This is a feature I'd really like to see in Cython. I'd be happy to help
>> with it, though I don't currently know enough about the internals of
>> Cython to do it without some guidance. What would be the best way to do
>> this? I've had three ideas thus far that might allow something like this
>> to work, but I'd really like to get some second opinions before I get
>> too far with any of them.
>>
>> 1. Make these array operations available as a part of Cython's memory
>> view objects.
>>
>> 2. Write a Cython wrapper around a NumPy-like C++
>> library. https://github.com/ContinuumIO/libdynd seems to be a good
>> candidate, though I'm not as familiar with it. (This doesn't strike me
>> as something that would be a part of the main Cython project, but it
>> could be a good way to make this sort of functionality available. It
>> seems like a good way to avoid a lot of duplicate work though.)
>>
>> 3. Write a Fortran backend for Cython that uses Fortran's arrays
>> wherever memory views are used.
>> (This could be a bit crazy, but with the iso_c_binding module, it might
>> be possible. It could also allow better optimizations for arrays to be
>> applied by the compiler.)
>>
>> What would be the best way to go about this?
>>
>
>4. Use numpy itself. numpy since 1.8 has vectorized base math functions,
>though for large arrays you have to apply manual blocking and inplace
>operations to see significant gains. That is where cython can help.
>Possibly numpy is also open to expose the raw data buffer functions in
>its api to make blocking more efficient.

Thank you for pointing that out. Using the machinery that is already built
in to numpy would be ideal. I hadn't realized that was a part of numpy's
API. If I understand correctly, you're referring to
https://github.com/numpy/numpy/blob/master/doc/neps/generalized-ufuncs.rst.
Is that the right portion of the API? I'll try and figure out how to use
it. Any working examples would be greatly appreciated. Other suggestions
are also still welcome
Thanks!
-Ian Henriksen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20140806/e4c09031/attachment.html>


More information about the cython-devel mailing list