Author skrah
Recipients pitrou, skrah
Date 2019-01-28.22:43:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548715410.64.0.576601049016.issue35845@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-01-28 22:43:32skrahsetrecipients: + skrah, pitrou
2019-01-28 22:43:30skrahsetmessageid: <1548715410.64.0.576601049016.issue35845@roundup.psfhosted.org>
2019-01-28 22:43:30skrahlinkissue35845 messages
2019-01-28 22:43:30skrahcreate