From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 2 Feb 2026 10:30:34 +0000 (+0100) Subject: [3.14] gh-144380: Fix incorrect type check in `buffered_iternext()` (GH-144381) ... X-Git-Tag: v3.14.3~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=343679ee6ab775c0f93befbb90ff6a236ff4d80f;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-144380: Fix incorrect type check in `buffered_iternext()` (GH-144381) (#144389) gh-144380: Fix incorrect type check in `buffered_iternext()` (GH-144381) (cherry picked from commit 40d07cad38bf3ce60f4ca03f1836e8650fe40df5) Co-authored-by: Ruiyang Ke --- 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 000000000000..4b5b1b3776d7 --- /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 25c8bf8b3d50..6b43161a73a6 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1493,8 +1493,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);