[SciPy-dev] [SciPy-user] default dtype

Francesc Altet faltet at carabos.com
Mon Jan 2 09:56:17 EST 2006


A Dilluns 02 Gener 2006 14:53, Ed Schofield va escriure:
> 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 ...

Yes. I think this would be really nice to have. That way, the
64/32-bit dichotomy would disappear.

> 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.

Frankly, I don't find this specially bad. If double would be the
default we have similar problems:

>>> a = zeros(10)
>>> a[0] = 1
>>> a[0]
1.0

i.e. the value has been upgraded without our knowlegde. Of course, you
may say that upgrading is always better than downgrading, but if we
follow this reasoning to the end, then complex128 should be the
default, which is somewhat crazy.

IMO, the user has to be concious about the default type when creating
arrays. Once he is used to the default, everything should go well. And
again, allowing a user-definable default would be very handy.

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"




More information about the SciPy-Dev mailing list