[Numpy-discussion] numpy and cython in pure python mode
Wed Sep 23 14:32:46 CDT 2009
Thanks for all the replies !
On Wed, Sep 23, 2009 at 4:55 AM, Dag Sverre Seljebotn
> Robert Kern wrote:
>> On Tue, Sep 22, 2009 at 01:33, Sebastian Haase <email@example.com> wrote:
>>> I'm not subscribed to the cython list - hoping enough people would
>>> care to justify my post here:
> The post might be justified, but it is a question of available knowledge
> as well. I nearly missed this post here. The Cython user list is on:
>>> I know that cython's numpy is still getting better and better over
>>> time, but is it already today possible to have numpy support when
>>> using Cython in "pure python" mode?
>>> I like the idea of being able to develop and debug code "the python
>>> way" -- and then just switching on the cython-overdrive mode.
>>> (Otherwise I have very good experience using C/C++ with appropriate
>>> typemaps, and I don't mind the C syntax)
>>> I only recently learned about the "pure python" mode on the sympy list
>>> (and at the EuroScipy2009 workshop).
>>> My understanding is that Cython's pure Python mode could be "played"
>>> in two ways:
>>> a) either not having a .pyx-file at all and putting everything into a
>>> py-file (using the "import cython" stuff)
>>> or b) putting only cython specific declaration in to a pyx file having
>>> the same basename as the py-file next to it.
> That should be a pxd file with the same basename. And I think that mode
> should work. b), that is.
That is really good news ! A short example would be very helpful,
since the "pure python mode" documentation is very sparse. I found
that one wiki page to be very good - but obviously it's not a complete
> Sturla's note on the memory view syntax doesn't apply as that's not in a
> released version of Cython yet, and won't be until 0.12.1 or 0.13. But
> that could be made to support Python mode a).
Using an svn version would be fine with me, however the mentioned
syntax (thanks Sturla) looks quite awkward/unnatural.
> Finally there's been some recent discussion on cython-dev about a tool
> which can take a pyx file as input and output pure Python.
This would probably only be a second-to-best solution because it would
effectively double the source code. (However, eventually such a tool
could run behind the scene and import the pyx-converted py file on the
fly -- in which case it would be transparent ...)
>>> One more: there is no way on reload cython-modules (yet), right ?
>> Correct. There is no way to reload any extension module.
> This can be worked around (in most situations that arise in practice) by
> compiling the module with a new name each time and importing things from
> it though. Sage already kind of support it (for the %attach feature
> only), and there are patches around for pyximport in Cython that's just
> lacking testing and review. Since pyximport lacks a test suite
> altogether, nobody seems to ever get around to that.
I read something like this in the archives, thanks for the update.
Will those patches be applied to svn - even if untested so far... ?
> Dag Sverre
-- Sebastian Haase
More information about the NumPy-Discussion