Re: [Numpy-discussion] best way for C code wrapping

2008-02-16 Thread Matthieu Brucher
Hi,

numpy.ctypes uses ctypes to work, it consists of some additional utility
functions.

There was a discussion on this some time ago (SWIG, ctypes, ...) with David
(C.), Gaƫl and others.

Why translating some code to C ? Why not using f2py ?

Matthieu

2008/2/16, dmitrey <[EMAIL PROTECTED]>:
>
> hi all,
> I intend to connect some C code to Python for some my purposes.
> What is the best software for the aim?
> Is it numpy.ctypes or swig or something else?
> IIRC ctypes are present in Python since v2.5, so it's ok to use just
> ctypes, not numpy.ctypes, or some difference is present?
>
> Another one question: if I'll translate a fortran code to C via f2c,
> which % of speed down should I expect (in average, using gfortran and
> gcc)? Afaik it contains operations with sparse matrices.
>
> Thank you in advance,
> D.
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] best way for C code wrapping

2008-02-16 Thread Albert Strasheim
Hello,

On Feb 16, 2008 9:14 PM, dmitrey <[EMAIL PROTECTED]> wrote:
> hi all,
> I intend to connect some C code to Python for some my purposes.
> What is the best software for the aim?
> Is it numpy.ctypes or swig or something else?
> IIRC ctypes are present in Python since v2.5, so it's ok to use just
> ctypes, not numpy.ctypes, or some difference is present?

I would definitely recommend ctypes. numpy.ctypes is just some extra
code to make it easier to use NumPy arrays with ctypes. It's not a
standalone thing.

There are some example of what you can do with the ctypes support in NumPy here:

http://www.scipy.org/Cookbook/Ctypes

Look for ndpointer.

> Another one question: if I'll translate a fortran code to C via f2c,
> which % of speed down should I expect (in average, using gfortran and
> gcc)? Afaik it contains operations with sparse matrices.

Depending on what you want to do exactly, you might consider wrapping
the Fortran code using f2py instead of translating it to C. You could
also build the Fortran code as a shared library and wrap it using
ctypes.

Regards,

Albert
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] best way for C code wrapping

2008-02-16 Thread dmitrey
hi all,
I intend to connect some C code to Python for some my purposes.
What is the best software for the aim?
Is it numpy.ctypes or swig or something else?
IIRC ctypes are present in Python since v2.5, so it's ok to use just 
ctypes, not numpy.ctypes, or some difference is present?

Another one question: if I'll translate a fortran code to C via f2c, 
which % of speed down should I expect (in average, using gfortran and 
gcc)? Afaik it contains operations with sparse matrices.

Thank you in advance,
D.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion