On Sat, Mar 15, 2014 at 3:41 AM, Nathaniel Smith <
njs@pobox.com> wrote:
> I think we need to
> know something about how often the Mat @ Mat @ vec type cases arise in
> practice. How often do non-scalar * and np.dot show up in the same
> expression? How often does it look like a * np.dot(b, c), and how often does
> it look like np.dot(a * b, c)? How often do we see expressions like
> np.dot(np.dot(a, b), c), and how often do we see expressions like np.dot(a,
> np.dot(b, c))? This would really help guide the debate. I don't have this
> data, and I'm not sure the best way to get it. A super-fancy approach would
> be to write a little script that uses the 'ast' module to count things
> automatically. A less fancy approach would be to just pick some code you've
> written, or a well-known package, grep through for calls to 'dot', and make
> notes on what you see. (An advantage of the less-fancy approach is that as a
> human you might be able to tell the difference between scalar and non-scalar
> *, or check whether it actually matters what order the 'dot' calls are done
> in.)
Okay, I wrote a little script [1] to scan Python source files look for things like 'dot(a, dot(b, c))' or 'dot(dot(a, b), c)', or the ndarray.dot method equivalents. So what we get out is: