Extend and improve `LOAD_COMMON_CONSTANT`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Currently LOAD_COMMON_CONSTANT only loads 7 not-so-common constants and does so fairly inefficiently.
It could be improved in two ways:
- Add some more constants, especially
None, but also"",True,Falseand-1 Make the constants that it does load both statically allocated and immortal to avoid the pointer chasing and incref operation. Onlyanyandallwould need changing.
After some consideration, I think it best to leave the common constants table per interpreter, and not statically allocate them.
- The changes to
anyandallmay be breaking. - We also need to handle
AssertionErrorandNotImplementedErrorwill be tricky to make static
They should all be immortal though, and stored as _PyStackRefs not PyObject *s.
Linked PRs
- gh-148971
- gh-149625
- gh-149688
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the LOAD_COMMON_CONSTANT entry point and inspect how the per-interpreter common constants table stores and returns values. Review the linked PRs before changing the design, especially the _PyStackRef, immortality, and any/all considerations. Done means the agreed common constants, including None, empty string, True, False, and -1, are handled without the rejected static-allocation approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100