[Numpy-discussion] How to avoid extra copying when forming an array from an iterator

srean srean.list@gmail....
Fri Jun 24 04:03:01 CDT 2011


To answer my own question, I guess I can keep appending to a array.array()
object and get a numpy.array from its buffer if possible.  Is that the
efficient way.

On Fri, Jun 24, 2011 at 2:35 AM, srean <srean.list@gmail.com> wrote:

> Hi,
>
> I have an iterator that yields a complex object. I want to make an array
> out of a numerical attribute that the yielded object possesses and that too
> very efficiently.
>
> My initial plan was to keep writing the numbers to a StringIO object and
> when done generate the numpy array using StringIO's buffer. But fromstring()
> method fails on the StringIO object, so does fromfile() or using the
> StringIO object as the initializer of an array object.
>
> After some digging I ran in to this ticket htt
> projects.scipy.org/numpy/ticket/1634 that has been assigned a low
> priority.
>
> Is there some other way to achieve what I am trying ? Efficiency is
> important because potentially millions of objects would be yielded.
>
> -- srean
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110624/af78be4c/attachment.html 


More information about the NumPy-Discussion mailing list