Describe the issue:
In the FNV-1a hash implementation, the 64-bit variant is never selected.
In the following code:
|
/* |
|
* Compute a size_t FNV-1a hash of the given data |
|
* This will use 32-bit or 64-bit hash depending on the size of size_t |
|
*/ |
|
size_t |
|
npy_fnv1a(const void *buf, size_t len) |
|
{ |
|
#if NPY_SIZEOF_SIZE_T == 8 |
|
return (size_t)npy_fnv1a_64(buf, len, FNV1A_64_INIT); |
|
#else /* NPY_SIZEOF_SIZE_T == 4 */ |
|
return (size_t)npy_fnv1a_32(buf, len, FNV1A_32_INIT); |
|
#endif |
|
} |
the selection between 32-bit and 64-bit implementations depends on NPY_SIZEOF_SIZE_T. However, this macro does not appear to be defined, so the condition always falls back to the 32-bit version (npy_fnv1a_32).
As a result, even on 64-bit platforms, the 64-bit FNV-1a implementation is never used.
Since npy_intp is typically defined to match size_t, it may be more appropriate to use NPY_SIZEOF_INTP instead.
Reproduce the code example:
import numpy as np
# This issue is in the C implementation and cannot be directly reproduced
# from Python. It can be observed by inspecting the compiled code path
# or preprocessing output, where NPY_SIZEOF_SIZE_T is not defined and
# the 32-bit path is always selected.
Error message:
Python and NumPy Versions:
2.5.0.dev0+git20260319.b9ccff1
3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 17.0.0 (clang-1700.6.3.2)]
Runtime Environment:
No response
How does this issue affect you or how did you find it:
No response
Describe the issue:
In the FNV-1a hash implementation, the 64-bit variant is never selected.
In the following code:
numpy/numpy/_core/src/multiarray/fnv.c
Lines 73 to 85 in 621413b
the selection between 32-bit and 64-bit implementations depends on
NPY_SIZEOF_SIZE_T. However, this macro does not appear to be defined, so the condition always falls back to the 32-bit version (npy_fnv1a_32).As a result, even on 64-bit platforms, the 64-bit FNV-1a implementation is never used.
Since
npy_intpis typically defined to matchsize_t, it may be more appropriate to useNPY_SIZEOF_INTPinstead.Reproduce the code example:
Error message:
Python and NumPy Versions:
2.5.0.dev0+git20260319.b9ccff1
3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 17.0.0 (clang-1700.6.3.2)]
Runtime Environment:
No response
How does this issue affect you or how did you find it:
No response