Controlling buffer alignment in file.read()

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Mar 18 19:08:30 EDT 2014


Haralanov, Mitko wrote:
> I am using Python to read from a binary device file which requires that all
> read sizes are in 8byte multiples and the user's buffer is 8byte aligned.
> 
> Is there a way that I can get file.read() to use an 8byte aligned buffer?

For control at that level you'd be better off using
direct system calls, i.e. os.open() and os.read(),
then you can read exacty the number of bytes you want.

-- 
Greg



More information about the Python-list mailing list