diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-25 20:01:33 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-25 20:01:33 (GMT) |
commit | fd8211372dc61374dd0280385285b64f190df28b (patch) | |
tree | 704434124057bad948f08b70ff50371160293f94 /Modules | |
parent | 242926d227445857efd5981dab67cdaf5657e25a (diff) | |
download | cpython-fd8211372dc61374dd0280385285b64f190df28b.zip cpython-fd8211372dc61374dd0280385285b64f190df28b.tar.gz cpython-fd8211372dc61374dd0280385285b64f190df28b.tar.bz2 |
Fast path for IncrementalNewlineDecoder.decode() in io.TextIOWrapper.read(-1)
Copy/paste code from textiowrapper_read_chunk().
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/textio.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 35bd922..70d062b 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1513,8 +1513,13 @@ textiowrapper_read(textio *self, PyObject *args) PyObject *decoded; if (bytes == NULL) goto fail; - decoded = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode, - bytes, Py_True, NULL); + + if (Py_TYPE(self->decoder) == &PyIncrementalNewlineDecoder_Type) + decoded = _PyIncrementalNewlineDecoder_decode(self->decoder, + bytes, 1); + else + decoded = PyObject_CallMethodObjArgs( + self->decoder, _PyIO_str_decode, bytes, Py_True, NULL); Py_DECREF(bytes); if (decoded == NULL) goto fail; |