[Numpy-discussion] appending extra items to arrays
Thu Oct 11 09:02:04 CDT 2007
On 10/10/07, Anne Archibald <email@example.com> wrote:
> On 11/10/2007, Robert Kern <firstname.lastname@example.org> wrote:
> > Appending to a list then converting the list to an array is the most
> > straightforward way to do it. If the performance of this isn't a
> problem, I
> > recommend leaving it alone.
> Just a speculation:
> Python strings have a similar problem - they're immutable, and so are
> even more resistant to growth than numpy arrays. For those situations
> where you really really want to grow a srting, python provides
> StringIO, where you keep efficiently adding to the string, then
> finalize it to get the real string out. Would something analogous be
> interesting for arrays?
Have you looked at array.array?
>>> import array
>>> a = array.array('i')
array('i', [2, 7])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion