Skip to content

gh-133342: Remove sym_is_const and sym_has_type #133884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tomasr8
Copy link
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
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 :).

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.

2 participants