471,328 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 software developers and data experts.

C extension question

I am currently trying to port some Python and Python C extension code
to C#, and am having trouble understanding what is happening in a
piece of the code.

The pertinent pieces of code are below, and my question follows the

in foo.py:
(mgrid,xgrid,ygrid,zgrid,ngrids) = IP.CreateGridCell()

in IP.c:
static PyObject *PyCreateGridCell()
GRIDCELL *grid = alloc(...);
for(i=0; i<length; i++)
grid[cnt] = .... //etc fill in grid array

PyObject *GRIDRET = PyCObject_FromVoidPtr((void *)grid,NULL);
return Py_BuildValue("Oi",GRIDRET,cnt-1);

typedef struct {
XYZ p[8];
double val[8];

typedef struct {
double x,y,z;
} XYZ;

So my question is (and I hope it's not too silly a question), what is
happening to the grid array pointer in the C code that it maps to
multiple variables (which all are arrays) on the python side. Is the
grid variable being assigned to mgrid, xgrid, ygrid and zgrid whole,
or is it being split somehow (and if so, how)? Thanks for the help.

Nov 1 '07 #1
0 801

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Gyger | last post: by
2 posts views Thread by Lee Stewart | last post: by
8 posts views Thread by Torsten Mohr | last post: by
3 posts views Thread by man-in-nature | last post: by
7 posts views Thread by Chris Kennedy | last post: by
13 posts views Thread by Matt | last post: by
5 posts views Thread by malkarouri | last post: by
4 posts views Thread by Steffen Bobek | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.