This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients aguiar, pitrou
Date 2009-03-15.16:05:26
SpamBayes Score 1.0880186e-12
Marked as misclassified No
Message-id <1237133197.6760.13.camel@fsol>
In-reply-to <1237132328.52.0.00731426523965.issue5396@psf.upfronthosting.co.za>
Content
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.
History
Date User Action Args
2009-03-15 16:05:28pitrousetrecipients: + pitrou, aguiar
2009-03-15 16:05:26pitroulinkissue5396 messages
2009-03-15 16:05:26pitroucreate