[Numpy-discussion] array comprehension

Chris Barker chris.barker at noaa.gov
Fri Nov 4 16:08:44 EDT 2016


On Fri, Nov 4, 2016 at 10:36 AM, Nathaniel Smith <njs at pobox.com> wrote:

> On Nov 4, 2016 10:32 AM, "Stephan Hoyer" <shoyer at gmail.com> wrote:
> > fromiter dynamically resizes a NumPy array, like a Python list, except
> with a growth factor of 1.5
>


> Oh, right, and the dtype argument is mandatory, which is what makes this
> possible.
>
Couldn't it determine the dtype from the first element, and then barf later
if an incompatible one shows up?

And then we could adapt this code to np.array() and get nice performance
with no extra functions to think about calling...

And off the top of my head, I can't think of why it couldn't be generalized
to the nd case as well.

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161104/0a4378e4/attachment.html>


More information about the NumPy-Discussion mailing list