Skip to content

Conversation

@markshannon
Copy link
Member

@markshannon markshannon commented Mar 4, 2024

Factors out the common logic for all TO_BOOL variants:

  • If the input is a bool, replace with a NOP
  • If the input is a "truthy" or "falsey" value, replace with a POP_TOP; LOAD_CONST True/False

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

LGTM. One minor formatting nit.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Nice.

@markshannon markshannon merged commit cbf3d38 into python:main Mar 5, 2024
@markshannon markshannon deleted the optimize-on-truthiness branch March 5, 2024 11:23
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants