scipy and cython

295 views
Skip to first unread message

samdashti

unread,
Oct 4, 2013, 4:43:31 PM10/4/13
to cython...@googlegroups.com
I see a lot of source on numpy and Cython. I am wondering whether scipy and cython can be used together as well. I am currently working on a project for which I have used LM from scipy library. need to see if I could use cython and get a c compilability out of it. many many thanks in advance!

Robert Bradshaw

unread,
Oct 4, 2013, 11:21:57 PM10/4/13
to cython...@googlegroups.com
Yes, Cython and SciPy can be used together just fine, just like any
other Python library. NumPy has special support because the overhead
of accessing individual elements in an array via the Python-exposed
API can be prohibitive, but SciPy doesn't introduce its own arrays so
you can use NumPy arrays with SciPy just fine.

Is there something that you're specifically trying to achieve?
Performance? Porting existing code?
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cython-users...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Menchyshyn Oleh

unread,
Oct 25, 2013, 9:13:12 PM10/25/13
to cython...@googlegroups.com
I am trying to use SciPy and Cython combination but with a little success. I know about huge optimization gain when using vectorized versions of algorithms based on NumPy, but I guess my problem depends on NumPy implicitly only, through 3D integration routine. My bottleneck is Python's function overhead passing many times to scipy.integrate.tplquad in the cycle of the scipy.optimize.fmin when searching for the roots of a set of non-linear equations. 

My question is: Is it possible to pass to SciPy's routines non-PyObjects? I read on the Stackoverflow that there were some thoughts about implementing those issues.

I tried other non-Python libraries for integrating and roots finding of non-lineaer sets of equations. But combining interfaces of different libs in C++ is error-prone and tedious sometime. I miss simplicity and readability of Python much. Please help me, maybe I just don't get something right with Cython+SciPy way 

Robert Bradshaw

unread,
Oct 31, 2013, 11:20:42 PM10/31/13
to cython...@googlegroups.com, SciPy Users List
If SciPy doesn't expose a C API, then you have to call it via the
Python API, which could very well be a bottleneck. If it does, then
you can call it like any other C library.

- Robert
Reply all
Reply to author
Forward
0 new messages