python / python/cpython

The IDENTIFIERS list in Tools/scripts/generate_global_objects.py is a slight burden

Open
#94,715 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

(This is partly inspired by gh-94706.)

In generate_global_objects.py, iter_global_strings() detects global strings by looking for _Py_ID() and _Py_DECLARE_STR() in the C source files. In some places those macros are used indirectly, which means the corresponding strings won't be detected by iter_global_strings().

Currently we manually add such strings to the IDENTIFIERS list at the top of the script. Before we added the discovery mechanism in iter_global_strings(), basically all the static strings were in this list. However, we found that there were several maintenance/development downsides to the manual list, so we added iter_global_strings(). At the time we didn't take the extra step of automating discovery of indirectly used names. We should address this.

CC @kumaraditya303

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Tools/scripts/generate_global_objects.py, focusing on iter_global_strings() and the manually maintained IDENTIFIERS list. Trace how the script scans C source files for _Py_ID() and _Py_DECLARE_STR(), then determine how indirectly used names can be discovered. Done means indirectly used global strings no longer require manual additions while generation remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
build-system, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.