Controlling buffer alignment in file.read()
Gregory Ewing
greg.ewing at canterbury.ac.nz
Tue Mar 18 20:07:12 EDT 2014
Haralanov, Mitko wrote:
> The problem is not controlling the number of bytes read. That part seems to
> be working. The issue is that the buffer into which the data is placed needs
> to be of certain alignment (8byte-aligned). Python does not seem to have a
> way that allows me to control that.
Hmmm, that could be tricky. Have you tried using os.read()?
If you're lucky, Python will be using a malloc() call or
equivalent to create a str/bytes object to read the data
into, and that will return something platform-aligned.
If you're unlucky, there's probably no pure-Python
solution, and you might need to write a small C or
Cython module to accomplish this trick.
--
Greg
More information about the Python-list
mailing list