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.