New submission from Kristján Valur Jónsson:

Some applications require reading http response data in "long" polls as it 
becomes available.  This is used, e.g. to receive "notifications" over a HTTP 
stream.
Using response.read(large_buffer) is not possible because this will attempt to 
fullfill the entire request (using multiple underlying recv() calls), negating 
the attempt to get data as it becomes available.
Using "readline", and using \n boundaries in the data, this problem can be 
overcome.
Currently, readline is slow because it will attempt to read one byte at a time. 
 Even if it is doing so from a buffered stream, it is still doing it one 
character at a time.
This patch adds a "peek" method to HttpResponse, which works both for chunked 
and non-chunked transfer encoding, thus improving the performance of readline.  
IOBase.readline will use peek() to determine the readahead it can use, instead 
of one byte which it must use by default.

----------
components: Library (Lib)
files: peek.patch
keywords: patch
messages: 197574
nosy: kristjan.jonsson
priority: normal
severity: normal
status: open
title: Enhance HTTPResponse.readline() performance
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file31741/peek.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19009>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to