Skip to content

gh-154902: Add an intrinsic for conditional annotations - #155026

Open
deadlovelll wants to merge 6 commits into
python:mainfrom
deadlovelll:gh-154902-intr
Open

gh-154902: Add an intrinsic for conditional annotations#155026
deadlovelll wants to merge 6 commits into
python:mainfrom
deadlovelll:gh-154902-intr

Conversation

@deadlovelll

Copy link
Copy Markdown
Contributor

Add an intrinsic for conditional annotations to avoid user to change them

For more details and discussion see gh-154902

Comment thread Lib/test/test_type_annotations.py Outdated
# gh-154902
def test_conditional_annotations_rebound_via_globals(self):
code = """
globals()["__conditional_annotations__"] = 0

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 guess we can parametrize both left side and right side:

{left} = {value}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thank you! just pushed the changes

Comment thread Python/intrinsics.c Outdated
deadlovelll and others added 3 commits August 1, 2026 16:05
Co-authored-by: sobolevn <mail@sobolevn.me>

@JelleZijlstra JelleZijlstra 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.

Thanks, this makes sense.

I think you'll also have to increase the bytecode magic number.

@deadlovelll

deadlovelll commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, this makes sense.

I think you'll also have to increase the bytecode magic number.

Thank you! Just pushed this, also added new intrinsic to the doc

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33867038 | 📁 Comparing 231fb8d against main (534b6b0)

  🔍 Preview build  

2 files changed
± library/dis.html
± whatsnew/changelog.html

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