Anne Archibald wrote:
> On 11/10/2007, Robert Kern <[EMAIL PROTECTED]> 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?

The Python version of StringIO, at least, just keeps a list, too. The primary
benefit of StringIO is that it exposes the file interface. For building up a
string/array, using the list is just as convenient (and for arrays, probably
more convenient given the variety of shapes one might want to build) and at
least as readable.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to