On 12/24/18, Drew Warwick <dwarwic...@gmail.com> wrote:
> The struct unpack API is inconvenient to use with files. I must do:
>
> struct.unpack(fmt, file.read(struct.calcsize(fmt))

Alternatively, we can memory-map the file via mmap. An important
difference is that the mmap buffer interface is low-level (e.g. no
file pointer and the offset has to be page aligned), so we have to
slice out bytes for the given offset and size. We can avoid copying
via memoryview slices. We can also use ctypes instead of
memoryview/struct.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to