Skip to content

Commit 343679e

Browse files
[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 40d07ca) Co-authored-by: Ruiyang Ke <me@ry.ke>
1 parent c766dda commit 343679e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve performance of :class:`io.BufferedReader` line iteration by ~49%.

Modules/_io/bufferedio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,8 @@ buffered_iternext(PyObject *op)
14931493

14941494
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
14951495
tp = Py_TYPE(self);
1496-
if (Py_IS_TYPE(tp, state->PyBufferedReader_Type) ||
1497-
Py_IS_TYPE(tp, state->PyBufferedRandom_Type))
1496+
if (tp == state->PyBufferedReader_Type ||
1497+
tp == state->PyBufferedRandom_Type)
14981498
{
14991499
/* Skip method call overhead for speed */
15001500
line = _buffered_readline(self, -1);

0 commit comments

Comments
 (0)