I have installed Anaconda 3 64 bit on my laptop and written the following code in Spyder:
import numpy.distutils.system_info as sysinfo import numpy as np import platform sysinfo.platform_bits platform.architecture() my_array = np.array([0,1,2,3]) my_array.dtype
Output of these commands show the following:
sysinfo.platform_bits Out[31]: 64 platform.architecture() Out[32]: ('64bit', 'WindowsPE') my_array = np.array([0,1,2,3]) my_array.dtype Out[33]: dtype('int32')
My question is that even though my system is 64bit, why by default the array type is int32 instead of int64?
Any help is appreciated.
The default data type: float_ . The 24 built-in array scalar type objects all convert to an associated data-type object.
We have a method called astype(data_type) to change the data type of a numpy array. If we have a numpy array of type float64, then we can change it to int32 by giving the data type to the astype() method of numpy array. We can check the type of numpy array using the dtype class.
int32 is an integer between -2^31 and 2^31 - 1. This range requires 32 bits of memory, and hence the name. Numpy allows for a variety of data types that are not present in regular Python, whose int type can be really, really large. Moreover, unlike Python's list, all elements of a Numpy array must be of the same type.
So the byte length is 8. I think 'np.int64()' means an integer in (-9223372036854775808 to 9223372036854775807) or an unsigned integer in (0 to 18446744073709551615)
Default integer type np.int_
is C long:
http://docs.scipy.org/doc/numpy-1.10.1/user/basics.types.html
But C long is int32 in win64.
https://msdn.microsoft.com/en-us/library/9c3yd98k.aspx
This is kind of a weirdness of the win64 platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With