[Matrix-SIG] Altering NumPy in lieu of unifying Python scalars.

Travis Oliphant Oliphant.Travis@mayo.edu
Wed, 12 Jan 2000 12:17:11 -0600 (CST)


Guido and others interested,

Just a quick note to let you know that I started to implement a unified
scalar object and got far enough to convince myself that it was possible
to do without any real disruption, but then I started to realize that it
may only have asthetic value.  My intent was to have a correspondence
between Python scalar types and NumPy array types, but this is a lot of
extra code to handle the rarely used single-precision-scalar cases.  NumPy
rank-0 arrays currently do very well as single-precision-scalars --- they
just have quite a bit of overhead.

My colleague and I have decided instead to alter NumPy sufficiently to fix
our biggest woes.  If Paul likes these changes then he is free to add them
to the main distribution.   Otherwise, this is important enough to me and
others in the community that a minor fork is justified.

1) We will change the behavior so that rank-0 NumPy are only converted to
Python scalars with PyArray_Return if there is an exact correspondence in
the precision with the current Python scalars.

2) We will fill in the slots in the PyNumberMethods table for the
arrayobject corresponding to nb_int, nb_float, nb_long, nb_oct, and
nb_hex, so that rank-0 arrays can be converted to Python scalars using the 
builtin functions int(), float(), long(), oct(), and hex() and at other
places within Python where it checks to see if the type knows how to be
an int.

We just wanted to let you and others know our plans in case somebody has
useful feedback or wants to offer their support.

Thanks,

Travis Oliphant