Loading binary data from a file into a buffer in Python

1k views Asked by At

I have a set of 640x480 images. I’m converting these images to a binary file format via Matlab… Now, I need to load each of the binary files into a buffer in Python, and then read data from that buffer. Can anyone help me out with how I might do that, or suggest a link? –Thanks.

1

There are 1 answers

0
fish2000 On

If you are using the C-API, you are going to want to use a Py_buffer structure (which is not a Python object – it is unrelated to PyObject*-compatible structures in the C-API).

If not using C, you will be interested in memoryview – the Python-level analog to Py_buffer – and the file I/O builtins and library module(s):