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 benjamin.peterson, hynek, nikratio, pitrou, r.david.murray, serhiy.storchaka, stutzbach
Date 2013-07-24.21:51:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1374702683.2619.5.camel@fsol>
In-reply-to <51F04B4F.1030105@rath.org>
Content
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)
History
Date User Action Args
2013-07-24 21:51:31pitrousetrecipients: + pitrou, benjamin.peterson, stutzbach, r.david.murray, nikratio, hynek, serhiy.storchaka
2013-07-24 21:51:31pitroulinkissue18524 messages
2013-07-24 21:51:31pitroucreate