Message334495
Yes, it's modeled after NumPy's tobytes():
>>> x = np.array(list(range(6)), dtype="int8").reshape(2,3)
>>> x.tobytes()
b'\x00\x01\x02\x03\x04\x05'
>>> x.T.tobytes()
b'\x00\x03\x01\x04\x02\x05'
>>>
>>>
>>> memoryview(x).tobytes()
b'\x00\x01\x02\x03\x04\x05'
>>> memoryview(x.T).tobytes()
b'\x00\x03\x01\x04\x02\x05'
I guess the reason is that without a type it's easier to serialize the logical array by default, so you can always assume C when you read back.
NumPy also has an 'F' parameter though that flips the order:
>>> x.tobytes('F')
b'\x00\x03\x01\x04\x02\x05'
It would be possible to add this to memoryview as well. |
|
Date |
User |
Action |
Args |
2019-01-28 22:43:32 | skrah | set | recipients:
+ skrah, pitrou |
2019-01-28 22:43:30 | skrah | set | messageid: <1548715410.64.0.576601049016.issue35845@roundup.psfhosted.org> |
2019-01-28 22:43:30 | skrah | link | issue35845 messages |
2019-01-28 22:43:30 | skrah | create | |
|