Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144380: Fix incorrect type check inbuffered_iternext()#144381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ruiyangke wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromruiyangke:fix/io/bufferedio-iternext-type-check

Conversation

@ruiyangke
Copy link

@ruiyangkeruiyangke commentedFeb 1, 2026
edited
Loading

Fix incorrect type check inbuffered_iternext() that prevented the fast path from ever being taken, causing ~15% slower iteration over buffered binary files.

Sincetp is already a type object,Py_IS_TYPE(tp, X) expands toPy_TYPE(tp) == X, which compares thetype itself againstBufferedReader. This is always false, so the fast path was never taken.

pyperf benchmark:

+----------------+---------+-----------------------+| Benchmark      | buggy   | fixed                 |+================+=========+=======================+| iteration      | 3.05 ms | 2.04 ms: 1.49x faster |+----------------+---------+-----------------------+

Closes:#144380

The condition used Py_IS_TYPE(tp, ...) where tp is already a `type`,this made the fast path unreachable.
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@python-cla-bot
Copy link

python-cla-botbot commentedFeb 1, 2026
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@colesbury
Copy link
Contributor

Thanks for catching this. Would you please add anews entry (blurb)?

@colesburycolesbury added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsFeb 1, 2026
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

awaiting reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Fast path inbuffered_iternext is never taken due to incorrect type check

2 participants

@ruiyangke@colesbury

[8]ページ先頭

©2009-2026 Movatter.jp