GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132732: Fix up pure types in JIT by Fidget-Spinner · Pull Request #136050 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Jun 27, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Constant evaluate/propagate pure ops automatically #132732

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Fidget-Spinner
Fix up pure types in JIT
004f28d
@Fidget-Spinner
Fidget-Spinner requested a review from tomasr8 as a code owner June 27, 2025 18:05
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 27, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Jun 27, 2025
Constant evaluate/propagate pure ops automatically #132732
Closed
@Fidget-Spinner Fidget-Spinner added the skip news label Jun 27, 2025
@Fidget-Spinner
Fidget-Spinner requested a review from brandtbucher June 27, 2025 18:05
@brandtbucher

brandtbucher commented Jun 27, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

How do you feel about recursively checking the tuple's elements for safety? Something like:

if (typ == &PyTuple_Type) {
    Py_ssize_t length = _Py_uop_sym_tuple_length(sym);
    if (length < 0) {
        return false;
    }
    for (Py_ssize_t i = 0; i < length; i++) {
        if (!_Py_uop_sym_is_safe_const(ctx, sym)) {
            return false;
        }
    }
    return true;
}

Potential downside is that in theory, the tuples could be huge. We could set an upper bound of a maximum of a few elements or something, though (but that gets tricky with the recursion, which could be arbitrarily deep too).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Jun 27, 2025

Copy link
Copy Markdown
Member Author

The tuples in the optimizer are limited to a size of 6, though that could recursively go on for a long time...

I think it's not worth thinking over. I don't think it's a common thing to use tuples in a "constant" way to do operations on. If they are, they would use lists instead. Unless of course they want to program in an immutable fashion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher

brandtbucher commented Jun 27, 2025

Copy link
Copy Markdown
Member

Constant tuples can be arbitrary size. This constant evaluation doesn’t operate on abstract tuples. But your point stands, probably better to ignore them for now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brandtbucher
brandtbucher approved these changes Jun 27, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jun 27, 2025
@Fidget-Spinner
Fidget-Spinner merged commit ff7b5d4 into python:main Jun 28, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Jun 28, 2025
@Fidget-Spinner
Fidget-Spinner deleted the clean-up-pure-types branch June 28, 2025 10:30
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
@Fidget-Spinner @AndPuQing
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
f8c108c
Fix up pure types in JIT
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@Fidget-Spinner @Pranjal095
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
08e6c82
Fix up pure types in JIT
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@Fidget-Spinner @taegyunkim
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
16ec67d
Fix up pure types in JIT
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@Fidget-Spinner @Agent-Hellboy
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
6869d45
Fix up pure types in JIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brandtbucher brandtbucher brandtbucher approved these changes
@tomasr8 tomasr8 Awaiting requested review from tomasr8 tomasr8 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Fidget-Spinner @brandtbucher
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.