[issue5396] os.read not handling O_DIRECT flag
Antoine Pitrou
report at bugs.python.org
Sun Mar 15 17:05:28 CET 2009
Antoine Pitrou <pitrou at free.fr> added the comment:
Hello Eduardo,
> 1) to allocated an aligned buffer it is as simple as allocate 4096 + len
> (buffer) and truncate address to 4k boundary.
Yes, but it is wasteful, especially since the common case is not to use
O_DIRECT. Also, os.read does not allocate a buffer, it allocates a whole
string object, and there's no way in the current Python object allocator
to choose a specific alignment boundary.
> 2) I wrote a floppy imager, and without O_DIRECT, it gives me 8 sectors
> (4k = kernel page) errors whenever one sector is bad.
Well, sorry for that... I guess Python is not well adapted to this (very
particular) use case.
Or you could write a C extension to read() to a properly aligned buffer,
or try to do it with ctypes.
> 3) There is os.O_DIRECT and os.open help page references it
I think the policy is to mirror all possible O_* constants, even if they
are of no use in Python. For example, we also have os.O_DIRECTORY.
Regards
Antoine.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5396>
_______________________________________
More information about the Python-bugs-list
mailing list