Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy array dtype is coming as int32 by default in a windows 10 64 bit machine

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.

like image 386
Prana Avatar asked Mar 29 '16 07:03

Prana


People also ask

What is the default Dtype in NumPy array?

The default data type: float_ . The 24 built-in array scalar type objects all convert to an associated data-type object.

How do I change the Dtype of a NumPy array?

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.

What does Dtype Int32 mean in Python?

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.

What does int64 mean in NumPy?

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)


1 Answers

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.

like image 198
Stop harming Monica Avatar answered Sep 21 '22 11:09

Stop harming Monica