Skip to content

gh-119053: Implement the fast path for list.__getitem__ - #119112

Merged
corona10 merged 8 commits into
python:mainfrom
corona10:gh-119053
May 21, 2024
Merged

corona10 merged 8 commits into
python:mainfrom
corona10:gh-119053

Conversation

@corona10

@corona10 corona10 commented May 17, 2024 •

Copy link
Copy Markdown
Member
@corona10 corona10 changed the title gh-119053: Implement the fast path for list.__getitem__ May 17, 2024
@corona10 corona10 changed the title [WIP] gh-119053: Implement the fast path for list.__getitem__ May 17, 2024
@corona10
corona10 requested review from colesbury and mpage May 17, 2024 06:48
@corona10
corona10 marked this pull request as ready for review May 17, 2024 06:48
Comment thread Objects/listobject.c Resolved
Comment thread Objects/listobject.c Resolved
@corona10
corona10 requested a review from mpage May 18, 2024 10:16

@mpage mpage left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I noticed that we perform a validity check on the index several times now:

  1. In list_item
  2. In list_get_item_ref
  3. In list_item_impl (if we end up taking the slow path)

While this doesn't affect correctness, I think it would make sense to refactor the code to eliminate the redundant checks given how performance sensitive this code is. That could be tackled in a separate PR, though.

Comment thread Objects/listobject.c Resolved
@colesbury colesbury added needs backport to 3.13 only security fixes labels May 20, 2024
@corona10
corona10 merged commit ab4263a into python:main May 21, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @corona10 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@corona10
corona10 deleted the gh-119053 branch May 21, 2024 13:49
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2024
…gh-119112)

(cherry picked from commit ab4263a)

Co-authored-by: Donghee Na <donghee.na@python.org>
@bedevere-app

bedevere-app Bot commented May 21, 2024

Copy link
Copy Markdown

GH-119309 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 21, 2024
corona10 added a commit that referenced this pull request May 21, 2024
…9112) (gh-119309)

gh-119053: Implement the fast path for list.__getitem__ (gh-119112)
(cherry picked from commit ab4263a)

Co-authored-by: Donghee Na <donghee.na@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants