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')
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/A2XKNKG4C55VKII6VOXRR3XEP6VHIU43/
Code of Conduct: http://python.org/psf/codeofconduct/