[SciPy-dev] Inclusion of cython code in scipy

Anne Archibald peridot.faceted@gmail....
Fri Apr 25 15:12:10 CDT 2008


On 25/04/2008, Nathan Bell <wnbell@gmail.com> wrote:
> On Fri, Apr 25, 2008 at 10:23 AM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
>  > 2008/4/25 Nathan Bell <wnbell@gmail.com>:
>  >
>  > >  Replacing exisiting Python/C/C++ code with Cython is my only objection.
>  >
>  >  Just to be clear: do you think using the raw NumPy and Python C API is
>  >  easier and cleaner than using Cython?
>
> That's a false dichotomy.  I think writing useful C/C++ libraries and
>  then interfacing them w/ SWIG/Cython or handwritten wrappers is a more
>  sustainable and safer approach.
>
>  IMO separating the wrappers from the implementation is a good idea.
>  Wrapping C code, especially C code that was written in a way conducive
>  to wrapping, is not difficult.  This holds true for SWIG/Cython/flavor
>  of the week.

If you're writing a pure C/C++ module to be interfaced by SWIG, how do
you use functions from the python API (or pure python functions from
scipy)? Can you do this without delving into the python C api?

To be clear: suppose I want to write a simulation object in raw C and
wrap it through SWIG. But in the (one-time) construction of the
simulation I want to use the percentile point function of the von
Mises distribution (conveniently available  as
scipy.stats.vonmises(x).ppf). Does SWIG let my pure C code easily get
at this function, or do I need to reimplement it myself?

Thanks,
Anne


More information about the Scipy-dev mailing list