Visitar URL original
gh-133342: Remove `sym_is_const` and `sym_has_type` by tomasr8 · Pull Request #133884 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20260516021702/https://github.com/python/cpython/pull/133884
Skip to content
/ cpython Public

gh-133342: Remove sym_is_const and sym_has_type#133884

Open
tomasr8 wants to merge 2 commits into
python:mainfrom
tomasr8:uop-simplifications
Open

gh-133342: Remove sym_is_const and sym_has_type#133884
tomasr8 wants to merge 2 commits into
python:mainfrom
tomasr8:uop-simplifications

Conversation

@tomasr8
Copy link
Copy Markdown
Member

@tomasr8 tomasr8 commented May 11, 2025 •

  • Simplify patterns such as
if (sym_is_const(ctx, flag)) {
  PyObject *value = sym_get_const(ctx, flag);
  // use value
}

into

PyObject *value = sym_get_const(ctx, flag);
if (value) {
  // use value
}
  • Remove sym_is_const and sym_has_type. They can be replaced by sym_get_const and sym_get_type respectively. This part is more of an exploration, these functions might still be useful in some situations. If we do decide to keep them, we can still simplify them quite a bit.

Check out the issue for more context!

@Fidget-Spinner
Copy link
Copy Markdown
Member

LGTM. But let's wait for #132733 to merge, then your diff can be smaller as half of the manual constants will be gone :).

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review skip news stale Stale PR or inactive for long period of time. topic-JIT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants