Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pass numeric arrays from C extensions to Python

18 views
Skip to first unread message

JBT

unread,
Sep 23, 2012, 9:39:42 PM9/23/12
to
Hi,

I am looking for a way to pass numeric arrays, such as *float a[100]; double b[200];*, from C extension codes to python. The use case of this problem is that you have data stored in a particular format, NASA common data format (CDF) in my case, and there exists an official C library to read/create/edit such data, and you want to do data analysis in python. The problem comes down to how to feed the data into python.

I did some googling, but so far no luck. Can anyone help me? Thank you very much.

Cheers,
JBT

Terry Reedy

unread,
Sep 23, 2012, 10:48:11 PM9/23/12
to pytho...@python.org
I would look into numpy and scipy.

--
Terry Jan Reedy

Grant Edwards

unread,
Sep 24, 2012, 10:55:37 AM9/24/12
to
On 2012-09-24, JBT <jianb...@gmail.com> wrote:

> I am looking for a way to pass numeric arrays, such as *float a[100];
> double b[200];*, from C extension codes to python. The use case of
> this problem is that you have data stored in a particular format,
> NASA common data format (CDF) in my case, and there exists an
> official C library to read/create/edit such data, and you want to do
> data analysis in python. The problem comes down to how to feed the
> data into python.

In a addition to scipy and scientific python (two different projects),
you should probably take a look at the struct module and the ctypes
module.

--
Grant Edwards grant.b.edwards Yow! Life is a POPULARITY
at CONTEST! I'm REFRESHINGLY
gmail.com CANDID!!
0 new messages