Antoine Pitrou added the comment: Le mercredi 24 juillet 2013 à 21:45 +0000, Nikolaus Rath a écrit : > The documentation is correct that read1(n) never returns more than n bytes. > > My complaint is that the actual bound is stricter than this, band > read1(n) will never return more than min(n, bufsize) bytes.
That's not really true. If the buffer is empty, read1(n) will try to read at most n bytes from the raw stream. So: - if the buffer is not empty, the whole buffer is returned and 0 raw I/O call is issued - if the buffer is empty, 1 raw I/O call is issued and at most 1 byte is returned Therefore, if you call read1(n) in a loop, all calls but the first will really try to read *n* bytes from the raw stream (because the first call will have emptied the buffer). (one implicit goal is to minimize the number of memory copies when returning data to the application; a well-known consumer of read1() calls is TextIOWrapper when it fills its internal buffer) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18524> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com