[SciPy-user] default dtype
schofield at ftw.at
Sun Jan 1 20:36:08 CST 2006
On 30/12/2005, at 7:14 PM, Travis Oliphant wrote:
> Alan G Isaac wrote:
>> Is an integer data type the obvious
>> default for 'empty'? I expected float.
> This question comes up occasionally. The reason for int is largely
> historical --- that's what was decided long ago when Numeric came out.
> Changing this in some places would break a lot of code, I'm afraid.
> And the default for empty is done for consistency. I felt it
> better to
> have one default rather than many.
> The default can be changed in one place in the C-code if we did decide
> to change it. Now's the time because version 1.0 is approaching
> in the
> next couple of months. Version 0.9 will be the first-of-the-year
+5 on changing the default to float. I think we'd look back on this
decision in several years as difficult but right.
Here are some ideas on how we could ease the transition:
(1) We could provide new functions intzeros(), intones(), and intempty
() with the same behaviour as the current functions. That is,
integer types would be the default, but this could be overridden by a
dtype keyword argument. Then converting any old Numeric / numarray
code would just require another global string substitution in
(2) We could provide two sets of functions, intzeros() etc. and
floatzeros() etc., and remove the default interpretation altogether
from the standard zeros() functions. This is not ideal long term,
but could be a useful temporary measure during a transition for
shaking out bugs from the scicore and scipy trees.
(3) The default type could be chosen by the user as a package-level
global variable. I think this would be the best solution. Then the
old integer default could be turned on with one line of Python code.
I suppose that Python functions using this default, given the static
evaluation of default argument values, would need the "dtype=None"
idiom in function headers followed by dtype=global_dtype in the
> SciPy-user mailing list
> SciPy-user at scipy.net
More information about the SciPy-user