[Python-Dev] towards a faster Python

Mark Russell mrussell@verio.net
Tue, 10 Jun 2003 01:06:59 +0100


Paul F Dubois <paul@pfdubois.com>:

>Making a module dictionary readonly after importation would break legendary
>amounts of code.

Perhaps a way round this would be to flag modules in some way.  For example,
an export statement with the following semantics:

    - Has the form "export name1, name2, name3"

    - Exported names must be bound in the module body (at some point
      after the export statement)

    - Export statements must appear before any others (apart from doc
      strings and comments)

    - The presence of the export statement makes binding or unbinding names
      in the module's dict illegal after the module has been loaded

    - Only exported names can be imported into other modules (in the same
      way as before - i.e. export would NOT imply automatic insertion into
      other namespaces)

    - No export statements means use the current rules (everything
      exported, module dict stays writable)

I think this would be an intuitively obvious addition, and these rules
would mean that the compiler would be free to make assumptions about the
meaning of builtins etc in a module.

Mark