https://github.com/python/cpython/commit/51fccc6059d7efb866ddf506d1721bcef8292926
commit: 51fccc6059d7efb866ddf506d1721bcef8292926
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-02-02T10:29:16Z
summary:

[3.13] gh-144380: Fix incorrect type check in `buffered_iternext()` (GH-144381) 
(#144390)

gh-144380: Fix incorrect type check in `buffered_iternext()` (GH-144381)
(cherry picked from commit 40d07cad38bf3ce60f4ca03f1836e8650fe40df5)

Co-authored-by: Ruiyang Ke <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst
M Modules/_io/bufferedio.c

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 65d69d0d5e13d0..2e8566168de4ba 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1486,8 +1486,8 @@ buffered_iternext(buffered *self)
 
     _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);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to