Antoine Pitrou <pit...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue5396> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com