On Tue, Dec 25, 2018 at 04:51:18PM -0600, eryk sun wrote: > On 12/24/18, Drew Warwick <[email protected]> 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.
Seems awfully complicated. How do we do all these things, and what advantage does it give? > We can also use ctypes instead of > memoryview/struct. Only if you want non-portable code. What advantage over struct is ctypes? -- Steve _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
