`_PyStaticCode_InternStrings` is called ~800 times during startup.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
The _Py_Deepfreeze_Init() function calls _PyStaticCode_InternStrings once for each string.
Creating the interned string dict in one go, from the table of static strings would be much faster.
something like this (error checking omitted, and other liberties taken for brevity)
_Py_CreateInternedDict(PyObject **strs, int n) {
PyDictKeys *table = make_dict_keys(n);
for (int i = 0; i < n; i++) {
table->entries[i].key = table->entries[i].value = strs[i];
table->entries[i].hashcode = strs[i].hash_code;
// Fix up size and entries here.
}
return new_dict(table);
}
All the hash codes will need to be initialized first, but we probably should do that anyway.
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 by tracing _Py_Deepfreeze_Init() and its calls to _PyStaticCode_InternStrings. Review how the interned string dictionary and string hash codes are initialized, then determine whether the proposed bulk construction preserves the required dictionary state and startup behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- backend, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100