[Numpy-discussion] FeatureRequest: support for array construction from iterators

Robert Kern robert.kern at gmail.com
Mon Dec 14 12:38:22 EST 2015


On Mon, Dec 14, 2015 at 3:56 PM, Benjamin Root <ben.v.root at gmail.com> wrote:

> By the way, any reason why this works?
> >>> np.array(xrange(10))
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

It's not a generator. It's a true sequence that just happens to have a
special implementation rather than being a generic container.

>>> len(xrange(10))
10
>>> xrange(10)[5]
5

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151214/7ce1d99b/attachment.html>


More information about the NumPy-Discussion mailing list