[SciPy-dev] [SciPy-user] default dtype
Ed Schofield
schofield at ftw.at
Mon Jan 2 07:53:17 CST 2006
Francesc Altet wrote:
>A Dilluns 02 Gener 2006 03:38, Ed Schofield va escriure:
>
>
>>+5 on changing the default to float. I think we'd look back on this
>>decision in several years as difficult but right.
>>
>>
>Sorry, but I don't agree. If we want Python to include the container
>for array objects, making the default be double seems to stress the
>fact that this object is meant primarily for scientific use (which is
>true to some extent). However, for the sake of stablishing a *real*
>standard to keep datasets, I'd advocate the default to remain int. In
>addition, there are a lot of uses for integer arrays (indices,
>images...). IMO, making the double the default would discourage the
>use of the object between people not used to write
>scientific/technical apps.
>
>The only issue is the possible confusion in users when they will
>receive Int32 arrays in 32-bit platforms and Int64 arrays in 64-bit
>ones. I don't know, but perhaps this single reason is strong enough to
>change the default to Float64.
>
>
Interesting point.
Then what do you think about an integer default that is redefinable by
the user? For example:
>>> import scicore / whatever
>>> scicore.default_dtype = float64
Then zeros(), empty(), and ones() (any others?) would use the new
default. I think the flexibility would be nice, and it should be
feasible ...
Perhaps the most compelling argument against an integer default is the
current behaviour with unsafe casting:
>>> a = zeros(10)
>>> a[0] = 1.159262
>>> a[0]
1
and this argument would evaporate if unsafe casts were required to be
more explicit. I promised to provide a patch and run some timings for
this, but I haven't done this yet.
-- Ed
More information about the Scipy-dev
mailing list