开发者

Numpy records in the c api

开发者 https://www.devze.com 2023-01-08 04:11 出处:网络
I\'m playing with writing some C code to speed up an inner loop in my python code. This loop operates on a numpy record, e.g. soemthing like

I'm playing with writing some C code to speed up an inner loop in my python code. This loop operates on a numpy record, e.g. soemthing like this:

a = numpy.zeros((10,), dtype=[("myfvalue" ,"float"), ("myc", "int8"),
                              ("anotheri", "uint64")])
开发者_StackOverflow社区

which is then passed into c code like so:

myCFunc(a, "blah")

I was wondering if someone had an example of how to access particular columns of "a" in the C func. Clearly, this is going to involve a PyArray_Descr.fields somewhere, but an example would really help make things clearer for me.


There are a number of examples on the Scipy Wiki:

  • C Extensions to NumPy and Python
0

精彩评论

暂无评论...
验证码 换一张
取 消