[Numpy-discussion] question about optimizing
Brian Blais
bblais at bryant.edu
Sat May 17 14:22:02 EDT 2008
On May 17, 2008, at May 17:11:52 AM, Alan G Isaac wrote:
> On Fri, 16 May 2008, Anne Archibald apparently wrote:
>> storing actual python objects in an array is probably not
>> a good idea
>
> I have been wondering what people use object arrays for.
> I have been guessing that it is for indexing convenience?
at least for me, that was the motivation. I am trying to build a
simulation framework for part of the brain, which requires connected
layers of nodes. A layer is either a 1D or 2D structure of nodes,
with each node a relatively complex beast. Rather than reinvent the
indexing (1D, 2D, slicing, etc...), I just inherited from ndarray. I
thought, after the fact, that some numpy functions on arrays would
help speed up the code, which consists mostly of calling an update
function on all nodes, passing each them an input vector. I wasn't
sure if there would be any speed up for this, compared to
for n in self.flat:
n.update(input_vector)
From the response, the answer seems to be no, and that I should
stick with the python loops for clarity. But also, the words of Anne
Archibald, makes me think that I have made a bad choice by inheriting
from ndarray, although I am not sure what a convenient alternative
would be.
bb
--
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080517/cb8403e7/attachment.html>
More information about the NumPy-Discussion
mailing list