Python and C, arrays

hinsen at cnrs-orleans.fr hinsen at cnrs-orleans.fr
Tue Jun 15 09:49:20 EDT 1999


John Fisher <jfisher at are.berkeley.edu> writes:

> I've run into a problem with a module I'm writing in C.  Basically, I
> need to be able to convert Python tuples or lists (it's unimportant
> which) into C arrays.  I know at compile-time the type of the array
(and
> that the tuple or list will be homogeneous, and of compatible type),
but
> I don't know the size.

The easiest solution by far is to use neither tuples nor lists, but arrays,
as implemented in the Numerical Python extension. The internal data structure
of such an array object *is* a C array. See
http://starship.python.net/crew/hinsen/NumPyExtensions.html for a tutorial on
using arrays in C extension modules. --
-----------------------------------------------------------------------------
-- Konrad Hinsen  | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique
Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron  | Fax: 
+33-2.38.63.15.17 45071 Orleans Cedex 2  | Deutsch/Esperanto/English/ France 
| Nederlands/Francais
-----------------------------------------------------------------------------
--


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list