Python and C, arrays

hinsen at hinsen at
Tue Jun 15 09:49:20 EDT 1999

John Fisher <jfisher at> 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
> that the tuple or list will be homogeneous, and of compatible type),
> 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 for a tutorial on
using arrays in C extension modules. --
-- Konrad Hinsen  | E-Mail: hinsen at Centre de Biophysique
Moleculaire (CNRS) | Tel.: +33- Rue Charles Sadron  | Fax: 
+33- 45071 Orleans Cedex 2  | Deutsch/Esperanto/English/ France 
| Nederlands/Francais

Sent via
Share what you know. Learn what you don't.

More information about the Python-list mailing list