[Matrix-SIG] Numeric Nits--a slightly different proposal

Min Xu minxu@scisun.sci.ccny.cuny.edu
Fri, 16 Jul 1999 16:29:19 -0400


> IMNSHO, the main reason for using the Forced types is to eliminate the 
> memory bloat which occurs when small types are upcast. If I declare an 
> array ForcedInt16, I want it to stay that way for the sake of conserving 
> memory. If I pass it to a function I don't want the function to be able to 
> override my type declaration and return an array cast to ForcedFloat32. If 
> I wanted a ForcedFloat32 I would have declared it that way from the start.
> 
> If the Forced types follow the normal promotion order, then the Forced type 
> system is just a hack to get around the python core's upcasting of scalars 
> to Float64. The reverse promotion order may be more surprising, but it is 
> also more in line with the original need for such a secondary type system, 
> and it gives the programmer more control over data-types and memory usage 
> during numerical computations.
> 
> But will any of this fix the integer division nit?
> -craig.
> 
Excuse me if I do not catch what this thread said. 
I will say it again the blind promotion of operation to Float64 is one of the 
main defect of Python to handle large data sets. As in other languages like C, 
Fortran, a promotion to the highest data type involved in the operation is 
reasonable. Other needs can always be met with a explicit cast.

When we can explicit cast any result to a desired data type, I think it can 
perform  any operations an extra fore data type attribute does. So I do not 
see any reason for a forced data type attribute.

But one concern is then for a function like sin(x), it should then be able to 
handle the following cases:
      sin( Float32 ) -> Float32,
      sin( Int32 ) -> Int32 ... etc
So we need some kind of overloading for operators and functions as in C++. 

This is another defect of Python. Correct me if it is not the case.








-- 
Min Xu				
City College of NY, CUNY		
Email:	mxu1@email.gc.cuny.edu
       	minxu@sci.ccny.cuny.edu	 
Tel:	(O) (212) 650-6865
	(O) (212) 650-5046
	(H) (212) 690-2119