<p dir="ltr">On 29 Oct 2014 01:47, "Alexander Belopolsky" <<a href="mailto:ndarray@mac.com">ndarray@mac.com</a>> wrote:<br>
><br>
><br>
> On Tue, Oct 28, 2014 at 9:23 PM, Nathaniel Smith <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br>
>><br>
>> OTOH trying to make .flat into a full duck-compatible ndarray-like<br>
>> type is a non-starter; it would take a tremendous amount of work for<br>
>> no clear gain.<br>
><br>
><br>
> I don't think so - I think all the heavy lifting is already done in flatiter.  The missing parts are mostly trivial things like .size or .shape or can be fudged by coercing to true ndarray using existing flatiter.__array__ method.</p>
<p dir="ltr">Now try .resize()... The full ndarray api is vast, and niggling problems would create endless maintenance issues. If your api is going to be that leaky then it's better not to have it at all.</p>
<p dir="ltr">> It would be more interesting however if we could always return a true ndarray view.  How is ndarray.diagonal() view implemented in 1.9?  Can something similar be used to create a flat view?</p>
<p dir="ltr">.diagonal has no magic, it just turns out that the diagonal of any strided array is also expressible as a strided array. (Specifically, new_strides = (sum(old_strides),).) There is no analogous theorem for flattening.</p>
<p dir="ltr">-n</p>