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

Benjamin Root ben.v.root at gmail.com
Mon Dec 14 12:41:45 EST 2015


Heh, never noticed that. Was it implemented more like a generator/iterator
in older versions of Python?

Thanks,
Ben Root

On Mon, Dec 14, 2015 at 12:38 PM, Robert Kern <robert.kern at gmail.com> wrote:

> 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
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151214/bfb07df9/attachment.html>


More information about the NumPy-Discussion mailing list