Describe the issue:
On Linux x86-64 Python 3.14.0 (installed from uv python, but I haven't tested other Python installations), I find that round-tripping an empty array through pickle is causing it to come back with a pointer that's unaligned.
Reproduce the code example:
import numpy
import pickle
empty = numpy.zeros((0,), dtype='u4')
assert empty.ctypes.data % 4 == 0 # Passes.
roundtrip = pickle.loads(pickle.dumps(empty))
print(f"{roundtrip.ctypes.data:#x}")
assert roundtrip.flags["ALIGNED"] # Passes.
assert roundtrip.ctypes.data % 4 == 0 # Typically fails.
Error message:
The roundtripped pointer came back as (e.g.) 0x17fd2a1, and then the final assertion fails.
Python and NumPy Versions:
Python: 3.14.0 from uv
Numpy: 2.3.4 (just pip install)
Runtime Environment:
[{'numpy_version': '2.3.4',
'python': '3.14.0 (main, Oct 14 2025, 21:27:55) [Clang 20.1.4 ]',
'uname': uname_result(system='Linux', node='guinea-pig', release='6.8.0-85-generic', version='#85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3', 'SSE41', 'POPCNT', 'SSE42'],
'not_found': ['AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL',
'AVX512_SPR']}},
{'architecture': 'Nehalem',
'filepath': '/home/jake/code/qiskit/venv314/lib/python3.14/site-packages/numpy.libs/libscipy_openblas64_-8fb3d286.so',
'internal_api': 'openblas',
'num_threads': 4,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.30'}]
Context for the issue:
A relatively minor problem for me: when interoperating with Rust, this causes us to need extra care before taking out Rust slices, because Rust slices require their backing pointer to be non-null and aligned, even for an empty slice.
Describe the issue:
On Linux x86-64 Python 3.14.0 (installed from
uv python, but I haven't tested other Python installations), I find that round-tripping an empty array throughpickleis causing it to come back with a pointer that's unaligned.Reproduce the code example:
Error message:
The roundtripped pointer came back as (e.g.)
0x17fd2a1, and then the final assertion fails.Python and NumPy Versions:
Python: 3.14.0 from
uvNumpy: 2.3.4 (just
pip install)Runtime Environment:
Context for the issue:
A relatively minor problem for me: when interoperating with Rust, this causes us to need extra care before taking out Rust slices, because Rust slices require their backing pointer to be non-null and aligned, even for an empty slice.