Hi Folks,
  I wonder if there's a way to fill an existing array from an iterator 
without creating a temporary array.  That is, I'm looking for something 
that has the effect of

  >>> target = np.array(xrange(9), dtype = float)
  >>> target[:] = np.fromiter(repeat(3.14159, 9), dtype=float)

without creating a second array object in the second line.  The closest 
I got was this:

  >>> target[:] = xrange(-9, 0)
  >>> target[:] = tuple(repeat(5.5, 9))

Note that xrange isn't really an iterator, and appears to be handled 
specially.  Emptying the iterator into a tuple works, but
I was hoping for something even more direct.  If this isn't possible, I 
wonder what people would think of adding an optional 'out' argument to 
the 'fromXXX' functions which behaved like the 'out' argument to sum() 
and other functions.

  Thanks,
     Ken
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to