A drive-by know-nothing comment: As a Python user I would be deliriously happy with a slightly less dynamic Python, if that was what was required to unlock the performance gains JITs in other contexts are capable of.
from __compiler__ import <list-of-compilation-options>
where the items in the list could be:
annotations_as_types → enforces the use of annotations as types, where deemed appropriate.
static_builtins ->All built-ins are “frozen” within the module and cannot be changed. This would make it possible to generate much more optimised code right at the bytecode level. E.g.: len(s) could generate specific bytecode that immediately calls the corresponding built-in function (or generate bytecode that reads the size field directly from the PyVarObject, if it already knows that s is an internal CPython type that “descends” from this object). By extending the import syntax slightly, one could select only the built-ins to be frozen (leaving all others in the usual built-in namespace):
from __compiler__ import static_builtins[int, float, complex, str, len]
Or to freeze them all except for a few:
from __compiler__ import static_builtins-[file, open]
frozen_globals → “freezes” all global variables at the end of the module’s initialisation. This makes it possible to access them directly using predefined array indices, completely bypassing dictionary hashing and lookup.
i8, i16, i32, i64, u8, u16, u32, u64 → signed and unsigned integer types of a specific size.
s_ascii, s_utf8, s_utf16, s_utf32, c_str → specific string types
single_inheritance → Classes can only be derived from a single base class (and, where applicable, from classes that act solely as interfaces), so as to utilise the classic VMT model, which is simpler and more efficient.
And so on. The possibilities are considerable, and can be further expanded. Obviously, this directive would also override the corresponding command-line or ENVAR parameters specifying the same settings, allowing you to selectively choose, in particular modules, to deviate from the global settings.