2

Why does the data type intc in numpy default to 32 bits when running 32-bit Anaconda with Python 2.7 on a 64-bit OS?

Example:

np.intc(1).dtype
#  dtype('int32')

Similarly:

type(np.intc(1))
#  <type 'numpy.int32'>

However:

import numpy.distutils.system_info as sysinfo
sysinfo.platform_bits
#  64

And similarly:

import platform
platform.architecture()
#  ('64bit', 'WindowsPE')

OS:

Windows 10 Enterprise

Anaconda:

conda version : 4.4.10
conda-build version : 3.4.1
python version : 2.7.14.final.0
channel URLs :        https://repo.continuum.io/pkgs/main/win-64
                      https://repo.continuum.io/pkgs/main/noarch
                      https://repo.continuum.io/pkgs/free/win-64
                      https://repo.continuum.io/pkgs/free/noarch
                      https://repo.continuum.io/pkgs/r/win-64
                      https://repo.continuum.io/pkgs/r/noarch
                      https://repo.continuum.io/pkgs/pro/win-64
                      https://repo.continuum.io/pkgs/pro/noarch
                      https://repo.continuum.io/pkgs/msys2/win-64
                      https://repo.continuum.io/pkgs/msys2/noarch
platform : win-64
noumenal
  • 1,077
  • 2
  • 16
  • 36

1 Answers1

3

np.intc is defined as an integer with the size of int in C in the compiler used to build the runtime (see here). In most modern compilers, even in 64-bit toolchains, int is defined to be 32 bits (see here). In your case you are using a 32-bit compilation of Python, the chances of a compiler producing 32-bit binaries having int defined as anything else than 32 are quite low.

You can check the size of int in one particular compiler with a program like the following:

#include  <stdio.h>

int main(void)
{
    printf("int size: %d bits.\n", sizeof(int) * 8);
    return 0;
}

You will see that most compilers will produce a program showing:

int size: 32 bits.
jdehesa
  • 58,456
  • 7
  • 77
  • 121