[SciPy-dev] array dtypechar wrong or not
oliphant at ee.byu.edu
Tue Oct 25 14:05:51 CDT 2005
Pearu Peterson wrote:
>In : array(array([1,2],dtype='I'),dtype='L').dtypechar
>In : array(array([1,2],dtype='L'),dtype='I').dtypechar
>I have expected 'L' and 'I', respectively. It this a bug?
It's not really a bug, Basically, on your platform 'I' and 'L' are
equivalent types, and so conversion is not done. I suppose that the
typenumber could change, though, instead of doing nothing.
Basically, it's the code in array_fromarray. Because 'I' and 'L' are
equivalent types on your platform, only an INCREF is done. If we
change the typecode as well as INCREF, then the original array would be
changed, which might be surprising as well:
a = array([1,2],dtype='I')
b = array(a,dtype='L')
b will point to a. If we change b to have typecode 'L', then a will
also change. This would be surprising, I think.
So, I guess, I don't think we should change the behavior.
More information about the Scipy-dev