Re: [Numpy-discussion] Strange behavior of operator *=
On 4/5/2011 9:26 AM, François Steinmetz wrote:
It does not change the dtype, 'int' is just interpreted as 'int64' :
So the meaning of 'int' is system specific? >>> import numpy as np; a=np.eye(2,dtype='int'); a.dtype dtype('int32') Alan Isaac
On 5. apr. 2011, at 15.39, Alan G Isaac wrote:
On 4/5/2011 9:26 AM, François Steinmetz wrote:
It does not change the dtype, 'int' is just interpreted as 'int64' :
So the meaning of 'int' is system specific?
import numpy as np; a=np.eye(2,dtype='int'); a.dtype dtype('int32')
Alan Isaac
'int' is system specific, 'int32' and 'int64' is not. At least, as far as I can tell. Paul.
On Tue, Apr 5, 2011 at 6:39 AM, Alan G Isaac <alan.isaac@gmail.com> wrote:
On 4/5/2011 9:26 AM, François Steinmetz wrote:
It does not change the dtype, 'int' is just interpreted as 'int64' :
So the meaning of 'int' is system specific?
>>> import numpy as np; a=np.eye(2,dtype='int'); a.dtype dtype('int32')
Yes, this is a fact about Python 'int', not a fact about numpy -- a Python 'int' is defined to hold a C 'long', which will be either 32 or 64 bits depending on platform. # 32-bit Linux: $ python -c 'import sys; print sys.maxint' 2147483647 # 64-bit Linux: $ python -c 'import sys; print sys.maxint' 9223372036854775807 -- Nathaniel
On 4/5/2011 10:37 AM, Nathaniel Smith wrote:
Yes, this is a fact about Python 'int', not a fact about numpy -- a Python 'int' is defined to hold a C 'long', which will be either 32 or 64 bits depending on platform.
So what is the rule for Python 3, where iiuc it can no longer be "a fact about Python"? Thanks, Alan Isaac
On Tue, Apr 5, 2011 at 8:44 AM, Alan G Isaac <alan.isaac@gmail.com> wrote:
On 4/5/2011 10:37 AM, Nathaniel Smith wrote:
Yes, this is a fact about Python 'int', not a fact about numpy -- a Python 'int' is defined to hold a C 'long', which will be either 32 or 64 bits depending on platform.
So what is the rule for Python 3, where iiuc it can no longer be "a fact about Python"?
At the c-api level I believe we still use the routines that convert python ints to longs. If we drop support for python < 2.6 we could change to using Py_ssize_t instead since there are python functions for that and we might get larger ints on 64 bit windows since windows longs are always 32 bits. That might also be compiler dependent however... Chuck
participants (4)
-
Alan G Isaac
-
Charles R Harris
-
Nathaniel Smith
-
Paul Anton Letnes