[Numpy-discussion] question about optimizing

Charles R Harris charlesr.harris at gmail.com
Sat May 17 15:13:05 EDT 2008


On Sat, May 17, 2008 at 1:02 PM, Anne Archibald <peridot.faceted at gmail.com>
wrote:

> 2008/5/17 Charles R Harris <charlesr.harris at gmail.com>:
> >
> >
> > On Sat, May 17, 2008 at 9:52 AM, Alan G Isaac <aisaac at american.edu>
> 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?
> >> Are there other core motivations?
> >
> > You can always define an object array of matrices, which solves Tim's
> > problem of matrix stacks, albeit in not the most efficient manner and not
> > the easiest thing to specify due to the current limitations of
> array(...). I
> > do think it would be nice to have arrays or arrays, but this needs one
> more
> > array type so that one can do something like array(list_of_arrays,
> > dtype=matrix((2,3),float)), i.e., we could use a fancier dtype.
>
> I think if you're going to be writing code to do this, it would be
> better not to use object arrays. After all, there no reason the
> underlysing storage for an array of matrices shouldn't be one big
> block of memory rather than a lot of scattered python objects.
>

Exactly, which is why I suggested an extension to dtype so that it could
also specify arraya. In that way matrix multiplication on matrix stacks
would simply go over to an element wise matrix multiplication. In that case,
dtype would also be nestable so that one could have arrays of arrays of
arrays ...

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080517/2c267c05/attachment.html>


More information about the NumPy-Discussion mailing list