Strictly defined integer.

This commit is contained in:
sun1638650145 2021-12-09 17:54:07 +08:00
parent 043adbc724
commit 74b027e586
2 changed files with 11 additions and 11 deletions

View File

@ -261,16 +261,16 @@ them mapping to respective C++ counterparts.
.. note::
This is a strict type, it will only allow input arguments of the specified
NumPy type and nothing else (e.g., ``py::numpy_scalar<int64_t>`` will not
accept built-in ``int`` or any other type for that matter).
This is a strict type, it will only allows to specify NumPy type as input
arguments, and does not allow other types of input parameters (e.g.,
``py::numpy_scalar<int64_t>`` will not accept Python's builtin ``int`` ).
.. note::
Native C types are mapped to NumPy types in a platform specific way: for
instance, ``char`` may be mapped to either ``np.int8`` or ``np.uint8``
depending on the platform. If you want to ensure specific NumPy types,
it is recommended to use fixed-width aliases from ``<cstdint>``.
and ``long`` may use 4 or 8 bytes depending on the platform. Unless you
clearly understand the difference and your needs, please use ``<cstdint>``.
Vectorizing functions
=====================

View File

@ -322,16 +322,16 @@ DECL_NPY_SCALAR(signed char, NPY_BYTE);
DECL_NPY_SCALAR(unsigned char, NPY_UBYTE);
// signed integer types
DECL_NPY_SCALAR(short, NPY_SHORT);
DECL_NPY_SCALAR(int, NPY_INT);
DECL_NPY_SCALAR(std::int16_t, NPY_SHORT);
DECL_NPY_SCALAR(std::int32_t, NPY_INT);
DECL_NPY_SCALAR(std::int64_t, NPY_LONG);
DECL_NPY_SCALAR(long, NPY_LONG);
DECL_NPY_SCALAR(long long, NPY_LONGLONG);
// unsigned integer types
DECL_NPY_SCALAR(unsigned short, NPY_USHORT);
DECL_NPY_SCALAR(unsigned int, NPY_UINT);
DECL_NPY_SCALAR(std::uint16_t, NPY_USHORT);
DECL_NPY_SCALAR(std::uint32_t, NPY_UINT);
DECL_NPY_SCALAR(std::uint64_t, NPY_ULONG);
DECL_NPY_SCALAR(unsigned long, NPY_ULONG);
DECL_NPY_SCALAR(unsigned long long, NPY_ULONGLONG);
// floating point types
DECL_NPY_SCALAR(float, NPY_FLOAT);