Difference between np.int, np.int_, int, and np.int_t in cython?

后端 未结 2 709
小蘑菇
小蘑菇 2020-12-12 17:27

I am a bit struggled with so many int data types in cython.

np.int, np.int_, np.int_t, int

I guess int in pure python

2条回答
  •  既然无缘
    2020-12-12 18:01

    np.int_ is the default integer type (as defined in the NumPy docs), on a 64bit system this would be a C long. np.intc is the default C int either int32 or int64. np.int is an alias to the built-in int function

    >>> np.int(2.4)
    2
    >>> np.int is int  # object id equality
    True
    

    The cython datatypes should reflect C datatypes, so cdef int a is a C int and so on.

    As for np.int_t that is the Cython compile time equivalent of the NumPy np.int_ datatype, np.int64_t is the Cython compile time equivalent of np.int64

提交回复
热议问题