C API: array of floats/ints from python to C and back

Scott David Daniels Scott.Daniels at Acm.Org
Sat Dec 27 18:15:43 EST 2008


Daniel Fetchinson wrote:
> I have considered using ctypes but for my needs using the C API
> directly seems more reasonable. array.array and numpy.array doesn't
> fit my needs since I need to do long and complicated operations on the
> two (pretty large) integer arrays that would be too slow using
> array.array and numpy.array (I've verified this claim by benchmarking
> a numpy.array based solution).

OK, but if you go to array.array or numpy.array or ctypes, you can
create a uniformly typed (C datatype) array , which is the key to
getting any speed out of the deal.  If you insist on using python
lists, you are stuck with extracting data element by element from
its Python language wrap.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list