[Numpy-discussion] big picture? One proposal
Konrad Hinsen
hinsen at cnrs-orleans.fr
Fri Mar 8 06:52:15 CST 2002
> regarding to consider arrays as a mathematical concept too. Just in
> mathematics I never (need to) use arrays in that way (my fields are
> mathematical analysis, integrable systems, and not computer science nor
I meant "mathematical" as a school of thought (going from the abstract
to the concrete), not as a domain of research. I don't know any area
of mathematics either that uses the array concept, but it is
definitely common in computer science (as a structured collection of
similar data). Image data is a good example.
> something can be accomplished efficiently. To be honest, I don't like
> programming in Python because it has a nice style, but because I can
> accomplish a lot with it in a very efficient way (and not only by using
I want both :-)
> > Moreover, I claim that Python *does* provide a good solution, it is
> > merely a very different one.
>
> So, what is it?
Separate matrix and array objects, with computationally efficient but
explicit (verbose) interconversion.
> Yes, it works:
> >>> from Numeric import *
> >>> class T: __rpow__ = lambda s,o: transpose(o)
> ...
> >>> print array([[1,2],[3,4]]) ** T()
> [[1 3]
> [2 4]]
Right, it works as long as the left argument doesn't try to do the
power operation itself.
> And I don't understand why it is abusive (because it is a different
> approach?). It's just an idea.
For me, "power" is a shorthand for repeated multiplication, with
certain properties attached to it. I have no problem with using the **
operator for something else, but then on different data types. The
idea that a**b could be completely different operations for the same a
as a function of b is not very appealing to me. In fact, the idea that
an operand instead of the operator defines the operation is not very
appealing to me.
There's also a more pragmatic objection which is purely technical, I
like to stay away from playing tricks with the binary operator type
coercion system in Python. Sooner or later it always bites back. And
the details have changed over Python releases, which is a
compatibility nightmare.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the Numpy-discussion
mailing list