[Numpy-discussion] Question about structure arrays

aerojockey pythondev1 at aerojockey.com
Sat Nov 7 16:18:22 EST 2015


Hello,

Recently I made some changes to a program I'm working on, and found that the
changes made it four times slower than before.  After some digging, I found
out that one of the new costs was that I added structure arrays.  Inside a
low-level loop, I create a structure array, populate it Python, then turn it
over to some handwritten C code for processing.  It turned out that, when
passed a structure array as a dtype, numpy has to parse the dtype, which
included calls to re.match and eval.

Now, this is not a big deal for me to work around by using ordinary slicing
and such, and also I can improve things by reusing arrays.  Since this is
inner loop stuff, sacrificing readability for speed is an appropriate
tradeoff.

Nevertheless, I was curious if there was a way (or any plans for there to be
a way) to compile a struture array dtype.  I realize it's not the
bread-and-butter of numpy, but it turned out to be a very convenient feature
for my use case (populating an array of structures to pass off to C).

Thanks



--
View this message in context: http://numpy-discussion.10968.n7.nabble.com/Question-about-structure-arrays-tp41653.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.



More information about the NumPy-Discussion mailing list