
Oct. 10, 2021
3:57 p.m.
10.10.21 18:18, Facundo Batista пише:
You mean `array` from the `array` module? The only way I see using it is like the following:
shm = shared_memory.SharedMemory(create=True, size=total_size) a = array.array('Q', nums) shm.buf[l_offset:r_offset] = a.tobytes()
But I don't like it because of the `tobytes` call, which will produce a huge bytearray only to insert it in the shared memory buffer.
That's why I liked `pack_into`, because it will write directly into the memory view.
Or I'm missing something?
shm.buf[l_offset:r_offset].cast('Q')[:] = a or shm.buf[l_offset:r_offset] = memoryview(a).cast('B')