Stephan Sahm
2015-11-27 10:37:17 UTC
ââ
[ this
ârequest
/discussion refers to numpy issue
ââ
ââ
#5863
â â
ââ
https://github.com/numpy/numpy/pull/5863#issuecomment-159738368 ]
Dear all,
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
ââ
ââ
#5863
<https://mail.google.com/mail/u/0/%E2%80%8Bhttps://github.com/numpy/numpy/pull/5863#issuecomment-159738368>
) - 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
âfeaturebranch (see
â
ââ
ââ
#5863
<https://mail.google.com/mail/u/0/%E2%80%8Bhttps://github.com/numpy/numpy/pull/5863#issuecomment-159738368>
â)
â
or something similar into numpy master
â.
Discussion, please!
âcheers,
Stephaân
[ this
ârequest
/discussion refers to numpy issue
ââ
ââ
#5863
â â
ââ
https://github.com/numpy/numpy/pull/5863#issuecomment-159738368 ]
Dear all,
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
ââ
ââ
#5863
<https://mail.google.com/mail/u/0/%E2%80%8Bhttps://github.com/numpy/numpy/pull/5863#issuecomment-159738368>
) - 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
âfeaturebranch (see
â
ââ
ââ
#5863
<https://mail.google.com/mail/u/0/%E2%80%8Bhttps://github.com/numpy/numpy/pull/5863#issuecomment-159738368>
â)
â
or something similar into numpy master
â.
Discussion, please!
âcheers,
Stephaân