[Numpy-discussion] FeatureRequest: support for array construction from iterators
Stephan.Sahm at gmx.de
Fri Nov 27 05:37:17 EST 2015
/discussion refers to numpy issue
As far as I can think, the expected functionality of np.array(...) would be
np.array(list(...)) or something even nicer.
Therefore, I like to request a generator/iterator support for np.array(...)
as far as list(...) supports it.
A more detailed reasoning behind this follows now.
In general it seems possible to identify iterators/generators as needed for
this purpose: - someone actually implemented this feature already (see
) - there is ``type.GeneratorType`` and ``collections.abc.Iterator``
for ``isinstance(...)`` check - numpy can destinguish them already from
all other types which get well translated into a numpy array
Given this, I think the general argument goes roughly like the following:
PROS (effect maybe 10% of numpy user or more): - more intuitive overall
behaviour, array(...) = array(list(...)) roughly - python3 compatibility
(see e.g. #5951 <https://github.com/numpy/numpy/issues/5951>) -
compatibility with analog ``__builtin__`` functions (see e.g. #5756
<https://github.com/numpy/numpy/issues/5756>) - all the above make numpy
easier to use in an interactive style (e.g. ipython --pylab) (computation
not that important, however coding time well) CONS (effect less than 0.1%
numpy user I would guess): - might break existing code
which in total, at least for me at this stage, speaks in favour of merging
the already existing
or something similar into numpy master
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion