You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fast path in buffered_iternext is never taken due to incorrect type check #144380
In Modules/_io/bufferedio.c, the buffered_iternext function has a fast path that calls _buffered_readline directly to avoid method call overhead.
However, due to an incorrect type check, this fast path is never executed.
tp=Py_TYPE(self);
if (Py_IS_TYPE(tp, state->PyBufferedReader_Type) ||Py_IS_TYPE(tp, state->PyBufferedRandom_Type))
because Py_IS_TYPE will call Py_TYPE internally, will cause Py_TYPE(Py_TYPE(ob)) == type, <class 'type'> != state->PyBufferedReader_Type
All iteration over buffered binary files is affected:
Activity
pythongh-144380: add news entry for BufferedReader performance improv…
pythongh-144380: Fix incorrect type check in buffered_iternext()
gh-144380: Fix incorrect type check in `buffered_iternext()` (#144381)
pythongh-144380: Fix incorrect type check in `buffered_iternext()` (p…
pythongh-144380: Fix incorrect type check in `buffered_iternext()` (p…
[3.13] gh-144380: Fix incorrect type check in `buffered_iternext()` (G…
[3.14] gh-144380: Fix incorrect type check in `buffered_iternext()` (G…
pythongh-144380: Fix incorrect type check in `buffered_iternext()` (p…
pythongh-144380: Fix incorrect type check in `buffered_iternext()` (p…