returning a python array from a C extension

Maxwell Todd Sayles sayles at cpsc.ucalgary.ca
Mon May 27 16:42:37 EDT 2002


in python i can write:

from array import *
a = array ('B', 'some test data')

and a refers to an array object.

now i have a C extension for python that returns a PyString, and within
python i can convert it to an array

e.g.:

from array import *
from MyCExtension import *
a = array ('B', cfunction())

but this method requires an extra copy and construction from the string
to the array.

is there a way i can have cfunction return a python array?  i tried
looking through the include files with the Python/C API and couldn't
find anything.  any help would be appreciated.

Thanks, Maxwell Sayles




More information about the Python-list mailing list