[Python-Dev] towards a faster Python

Guido van Rossum guido@python.org
Mon, 09 Jun 2003 16:13:22 -0400


> Make the module dict read-only and some as-yet-to-be-determined time
> during import?  That is, upon initial import of a module the dict
> collecting names would be made writable, but once it's associated
> with a module object (or the import is completed), the dict would be
> flagged read-only or be transmogrified into a read-only dict
> subclass of dict().

But the dict is still accessible in writable form through globals()
and as the func_globals attribute of any function defined in the
module.  This can't be helped unless we want to totally freeze a
module's contents after it's been imported.

Another hole in the plan is exec statements, or execfile() calls.

I still would like to be able to say "if you add a module global that
corresponds to a built-in name used in the module, the module may
continue to use the built-in name".  As long as we can detect *most*
of the ways of inserting such module globals, the remaining ways could
be declared illegal without making them impossible.

--Guido van Rossum (home page: http://www.python.org/~guido/)