[Numpy-discussion] Question about structure arrays
othalan at othalan.net
Mon Nov 9 09:27:19 EST 2015
On Nov 7, 2015 2:58 PM, "aerojockey" <pythondev1 at aerojockey.com> wrote:
> Recently I made some changes to a program I'm working on, and found that
> changes made it four times slower than before. After some digging, I
> 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
> 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
> and such, and also I can improve things by reusing arrays. Since this is
> inner loop stuff, sacrificing readability for speed is an appropriate
> Nevertheless, I was curious if there was a way (or any plans for there to
> 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
> for my use case (populating an array of structures to pass off to C).
I was just looking into structured arrays. In case it is relevant: Are you
using certain 1.10? They are apparently a LOT slower than 1.9.3, an issue
which will be fixed in a future version.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion