From 40d07cad38bf3ce60f4ca03f1836e8650fe40df5 Mon Sep 17 00:00:00 2001 From: Ruiyang Ke Date: Mon, 2 Feb 2026 02:04:18 -0800 Subject: [PATCH 1/2] gh-144380: Fix incorrect type check in `buffered_iternext()` (#144381) --- .../Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst | 1 + Modules/_io/bufferedio.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst diff --git a/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst b/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst new file mode 100644 index 00000000000000..4b5b1b3776d735 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst @@ -0,0 +1 @@ +Improve performance of :class:`io.BufferedReader` line iteration by ~49%. diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 6d779abd89ca84..0fdae7b2d21004 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1505,8 +1505,8 @@ buffered_iternext(PyObject *op) _PyIO_State *state = find_io_state_by_def(Py_TYPE(self)); tp = Py_TYPE(self); - if (Py_IS_TYPE(tp, state->PyBufferedReader_Type) || - Py_IS_TYPE(tp, state->PyBufferedRandom_Type)) + if (tp == state->PyBufferedReader_Type || + tp == state->PyBufferedRandom_Type) { /* Skip method call overhead for speed */ line = _buffered_readline(self, -1); From 092ef634f57909651c7699a3c750b16a1c0b63af Mon Sep 17 00:00:00 2001 From: Guilherme Leobas Date: Mon, 2 Feb 2026 07:30:17 -0300 Subject: [PATCH 2/2] docs: update dangling reference to `LOAD_METHOD` in dis.rst (#144358) --- Doc/library/dis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 755d681b9df2be..1486eeb3053da4 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1642,7 +1642,7 @@ iterations of the loop. Pushes a ``NULL`` to the stack. Used in the call sequence to match the ``NULL`` pushed by - :opcode:`!LOAD_METHOD` for non-method calls. + :opcode:`LOAD_ATTR` for non-method calls. .. versionadded:: 3.11