I floated the idea of freezing modules for import speed a little bit ago, but Steve Dower poured some cold water on the idea[1]. It’s a little bit related to this idea, though–if a set of stdlib modules were frozen, they could be marked read-only and more aggressively optimized
One way to implement this is as a runtime flag, e.g. python -X frozen-std=true
or something, which is by default off. In that case, it could become the default behavior over the course of a few versions, if the performance improvement was worth it. I suspect it would be worth it for a majority of users who aren’t modifying modules in the stdlib at all.
apparently it doesn’t speed things up much ↩︎