[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 40d07cad38)

Co-authored-by: Ruiyang Ke <me@ry.ke>
This commit is contained in:
Miss Islington (bot) 2026-02-02 11:30:34 +01:00 committed by GitHub
parent c766dda80d
commit 343679ee6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -0,0 +1 @@
Improve performance of :class:`io.BufferedReader` line iteration by ~49%.

View file

@ -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);