Skip to content

Commit 40d07ca

Browse files
authored
gh-144380: Fix incorrect type check in buffered_iternext() (#144381)
1 parent 3a0e183 commit 40d07ca

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
@@ -1505,8 +1505,8 @@ buffered_iternext(PyObject *op)
15051505

15061506
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
15071507
tp = Py_TYPE(self);
1508-
if (Py_IS_TYPE(tp, state->PyBufferedReader_Type) ||
1509-
Py_IS_TYPE(tp, state->PyBufferedRandom_Type))
1508+
if (tp == state->PyBufferedReader_Type ||
1509+
tp == state->PyBufferedRandom_Type)
15101510
{
15111511
/* Skip method call overhead for speed */
15121512
line = _buffered_readline(self, -1);

0 commit comments

Comments
 (0)