Consistent numeric type check Consistent numeric type check numpy numpy

Consistent numeric type check


the classes in numbers are Abstract Base Classes, you can register numpy.int* as Integral:

import numpy as npimport numbersnumbers.Integral.register(numpy.integer)a = np.int16(100)isinstance(a, numbers.Integral)

But the range of numpy.int16 is smaller than int, if you do calculation with numpy.int16, overflow may occurred.