Ah, I see. That sentence was meant as an alternative to the previous one,
i.e., the first point is that keeping track of which functions expect what
is impossible, so the obvious alternative is to write functions in such a
way that you don't need to keep track, but that is also impossible...


On Fri, Apr 11, 2014 at 1:27 PM, Lars Buitinck <notifications@github.com>wrote:

> In doc/neps/return-of-revenge-of-matmul-pep.rst:
>
> > +possible to switch between the conventions, because numpy provides two
> > +different types with different ``__mul__`` methods.  For
> > +``numpy.ndarray`` objects, ``*`` performs elementwise multiplication,
> > +and matrix multiplication must use a function call (``numpy.dot``).
> > +For ``numpy.matrix`` objects, ``*`` performs matrix multiplication,
> > +and elementwise multiplication requires function syntax.  Writing code
> > +using ``numpy.ndarray`` works fine.  Writing code using
> > +``numpy.matrix`` also works fine.  But trouble begins as soon as we
> > +try to integrate these two pieces of code together.  Code that expects
> > +an ``ndarray`` and gets a ``matrix``, or vice-versa, may crash or
> > +return incorrect results.  Keeping track of which functions expect
> > +which types as inputs, and return which types as outputs, and then
> > +converting back and forth all the time, is incredibly cumbersome and
> > +impossible to get right at any scale.  Functions that defensively try
> > +to handle both types as input and DTRT, find themselves floundering
> > +into a swamp of ``isinstance`` and ``if`` statements.
>
> @rkern <https://github.com/rkern> I agree with you. What I was really
> trying to point out is that DTRT is ambiguous in this context, because to a
> new user there may seem to be two "obvious" ways of "doing it right".
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/4351/files#r11529482>
> .
>



-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org