sebastian at sipsolutions.net
Tue Jul 23 12:35:54 EDT 2013
On Tue, 2013-07-23 at 10:22 -0600, Charles R Harris wrote:
> On Tue, Jul 23, 2013 at 8:46 AM, Pauli Virtanen <pav at iki.fi> wrote:
> 23.07.2013 17:34, Benjamin Root kirjoitti:
> > Don't assume .flat is not commonly used. A common idiom in
> matlab is
> > "a[:]" to flatten an array. When porting code over from
> matlab, it is
> > typical to replace that with either "a.flat" or
> "a.flatten()", depending
> > on whether an iterator or an array is needed.
> It is much more rarely used than `ravel()` and `flatten()`, as
> can be
> verified by grepping e.g. the matplotlib source code.
> Grepping in my code, I find a lot of things like
> dfx = van.dot((ax2 - ax1).flat)
> IIRC, the flat version was faster than other methods.
Faster then flatten certainly (since flatten forces a copy), I would be
quite surprised if it is faster then ravel, and since dot can't make use
of the iterator, that seems more natural to me.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion