Skip to content

Commit 51fccc6

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

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
@@ -1486,8 +1486,8 @@ buffered_iternext(buffered *self)
14861486

14871487
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
14881488
tp = Py_TYPE(self);
1489-
if (Py_IS_TYPE(tp, state->PyBufferedReader_Type) ||
1490-
Py_IS_TYPE(tp, state->PyBufferedRandom_Type))
1489+
if (tp == state->PyBufferedReader_Type ||
1490+
tp == state->PyBufferedRandom_Type)
14911491
{
14921492
/* Skip method call overhead for speed */
14931493
line = _buffered_readline(self, -1);

0 commit comments

Comments
 (0)