[vtkusers] pystrings

rharder at uiuc.edu rharder at uiuc.edu
Mon Apr 11 12:52:28 EDT 2005


Thanks Prabhu,
I've never been able to come to grips with the numarray c api.
I use
static PyObject* NA_vNewArray(void *buffer, NumarrayType type, int ndim, 
maybelong *shape)
to get my double* data into python numarrays.  This function also
creates a copy of the buffer.
How should I be doing this?

Ross

---- Original message ----
>Date: Sat, 9 Apr 2005 16:28:04 +0530
>From: Prabhu Ramachandran <prabhu_r at users.sourceforge.net>  
>Subject: Re: [vtkusers] pystrings  
>To: rharder at uiuc.edu
>Cc: vtkusers at vtk.org
>
>>>>>> "RH" == rharder  <rharder at uiuc.edu> writes:
>
>    RH> hi, I'm using PyString_FromStringAndSize to get c arrays into
>    RH> python then vtk datasets.  Is there a way to do this that does
>    RH> not generate a copy of the array as PyString_FromStringAndSize
>    RH> does?
>
>Use something like this:
>
> vtk_array.SetVoidArray(num_array_flat, len(num_array_flat), 0)
>
>Then remember to save a reference to the numeric array if not you'll
>get a nice segfault.
>
>cheers,
>prabhu



More information about the vtkusers mailing list