[Python-checkins] cpython: Fast path for IncrementalNewlineDecoder.decode() in io.TextIOWrapper.read(-1)
victor.stinner
python-checkins at python.org
Wed May 25 22:04:08 CEST 2011
http://hg.python.org/cpython/rev/6a2ca77b2c07
changeset: 70380:6a2ca77b2c07
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed May 25 22:01:33 2011 +0200
summary:
Fast path for IncrementalNewlineDecoder.decode() in io.TextIOWrapper.read(-1)
Copy/paste code from textiowrapper_read_chunk().
files:
Modules/_io/textio.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1513,8 +1513,13 @@
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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list