[PYTHON MATRIX-SIG] Finalized 0.3 interface (hopefully)

Hinsen Konrad hinsenk@ere.umontreal.ca
Fri, 19 Jan 1996 12:03:00 -0500


   After thinking about this a bit, I'm quite comformable with the
   __array__ member idea, because there is a precedent with __float__,
   __int__, and __long__.  However, I have a *strong* opinion that
   __array__ should be a member *function* that returns an instance as an
   array.  This is in keeping with __float__, __long__, etc.  If a
   user-defined type wants to store it's data in an array data member and
   return the member, it can, but other user-defined classes may want to
   compute and return array data on demand.

I agree that this would be better, but I worry about efficiency.
Function calls in Python are notoriously slow and should be avoided.

   Now, you don't want to have to type ",Spam" everytime, not because you
   don't like typing, but because you don't want the clutter, so you
   define a "sin" method in Spam:

       def sin(self): return sin(self,self.class)

   so then you could do:

       bar=foo.sin()

   I realize that this is not quite as pretty as the first version (or is
   it?), but it feels cleaner overall to me.  In the case of

Actually, when you import "sin" from umath, sin(foo) will automatically
be translated into foo.sin(). Again, I worry about the additional
overhead of a Python function call.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================