new Uint8Array(new Uint16Array([64]).buffer)
How can I achieve same result structure with pure Python? What is an equivalent of Uint8Array/Uint16Array?
I'm getting buffer from Uint16Array type here and cast to Uint8Array, however I'm not sure how can I achieve similar behavior in Python. I was trying to play with bytearray, but for me it looks different.
[EDIT]
const uint16 = new Uint16Array([32 + 32]);
const uint16buffer = uint16.buffer;
console.log('uint16', uint16);
console.log('uint16buffer', uint16buffer);
const uint8 = new Uint8Array(uint16buffer);
console.log('uint8', uint8);
const data = new Uint8Array(new Uint16Array([32 + 32]).buffer);
console.log('data', data);
Returns output like below:
uint16 Uint16Array(1) [ 64 ]
uint16buffer ArrayBuffer { [Uint8Contents]: <40 00>, byteLength: 2 }
uint8 Uint8Array(2) [ 64, 0 ]
data Uint8Array(2) [ 64, 0 ]