Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reducing I/O by using buffers and memoryviews #67

Open
armijnhemel opened this issue Apr 25, 2022 · 4 comments
Open

reducing I/O by using buffers and memoryviews #67

armijnhemel opened this issue Apr 25, 2022 · 4 comments

Comments

@armijnhemel
Copy link

This is something that I haven't fully thought out yet, but which might be useful in certain cases, such as when io is shared between elements (so when no new substreams are created). There are mechanisms in Python to reduce I/O and prevent unnecessary copying of data by using buffers and memoryviews. An article explaining it can be found here:

https://eli.thegreenplace.net/2011/11/28/less-copies-in-python-with-the-buffer-protocol-and-memoryviews

@KOLANICH
Copy link
Contributor

kaitai-io/kaitai_struct#277
kaitai-io/kaitai_struct#65

are related. Mmaps are memory views.

@armijnhemel
Copy link
Author

kaitai-io/kaitai_struct#277 kaitai-io/kaitai_struct#65

are related. Mmaps are memory views.

Not according to the documentation:

"Create a memoryview that references object. object must support the buffer protocol. Built-in objects that support the buffer protocol include bytes and bytearray."

https://docs.python.org/3/library/stdtypes.html#memoryview

As far as I can tell mmap does not support the buffer protocol.

@KOLANICH
Copy link
Contributor

KOLANICH commented May 6, 2022

@armijnhemel, my bad, you are right. To work with mmaps as with memory views we really have to wrap it into it. Thanks for fixing me.

@KOLANICH
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants