Skip to content

GH-115651: Convert LOAD_MODULE_ATTR into LOAD_INLINE_CONST when the module is itself a constant. - #115711

Merged
markshannon merged 6 commits into
python:mainfrom
faster-cpython:load-attr-module-const
Feb 22, 2024
Merged

GH-115651: Convert LOAD_MODULE_ATTR into LOAD_INLINE_CONST when the module is itself a constant.#115711
markshannon merged 6 commits into
python:mainfrom
faster-cpython:load-attr-module-const

Conversation

@markshannon

@markshannonmarkshannon commented Feb 20, 2024

Copy link
Copy Markdown
Member

Module attributes are global variables from other modules. It makes sense to convert them to constants as we already do for global variables.

Comment threadPython/optimizer_analysis.c

@Fidget-SpinnerFidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks good, just one change requested. Thanks!

Comment threadPython/optimizer_analysis.c
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c

@gvanrossumgvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have some clarity concerns (based on how long it took me to follow what's happening here) but the basics look good, other than (I think) a missing break.

Comment threadPython/optimizer_analysis.c
Comment threadPython/optimizer_analysis.c
Comment threadPython/optimizer_analysis.c
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c Outdated
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c Outdated
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c

@Fidget-SpinnerFidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM I just have a few questions

Comment threadPython/optimizer_analysis.c
Comment threadPython/tier2_redundancy_eliminator_bytecodes.c
@markshannon
markshannon merged commit b348313 into python:mainFeb 22, 2024
@markshannon
markshannon deleted the load-attr-module-const branch March 1, 2024 15:29
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@markshannon@gvanrossum@Fidget-Spinner