[SciPy-dev] Question about 64-bit integers being cast to double precision

Travis Oliphant oliphant at ee.byu.edu
Wed Oct 26 17:35:58 CDT 2005


Charles R Harris wrote:

>     Since the 'mental slot' is already in scipy's users heads for
>     saying 'modify
>     the default output of this function to accumulate/store data in a
>     different
>     type', I think it would be reasonable to offer
>
>     sqrt(a,rtype=float)
>

This would requires some rewriting of the internals which might be 
tricky to get right because of the conflict with the optional output 
arguments that are already available. 

Look at sqrt.types

This shows you the types that actually have functions available.  
Everything else has to be cast to something.  Right now, the rule is 
basically, don't cast unless we can "safely,"  where the notion of 
"safely" is defined in a switch-statement.

I suppose some way to bypass this default function selection and pick 
the function you specify instead might be useful, especially because 
with the way type conversion is handled now through a buffer, it is a 
lot different (for large arrays) to cast during calculation of a ufunc 
then to do sqrt(a.astype(float)) which would make a copy of the data 
first.  

-Travis





More information about the Scipy-dev mailing list