You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiprocessing returns Array, RawArray of wrong length python 3.10.4 #98447
The buffer interface doesn't retain type information about the items in the array, so using np.frombuffer defaults to double (8 bytes per item), even when the type in the array is i (4 bytes per item) since converting to a buffer throws that information out.
I think you want to use np.asarray(a) instead to get the behaviour you want -- it will correctly look at the type of the array (using the memoryview API), and it likewise avoids the memory copy.
Activity
mdboom commentedon Oct 19, 2022
The buffer interface doesn't retain type information about the items in the array, so using
np.frombufferdefaults todouble(8 bytes per item), even when the type in the array isi(4 bytes per item) since converting to a buffer throws that information out.I think you want to use
np.asarray(a)instead to get the behaviour you want -- it will correctly look at the type of the array (using the memoryview API), and it likewise avoids the memory copy.tendermonster commentedon Oct 20, 2022
Thanks for quick response