[Python-Dev] Making builtins more efficient

Jim Jewett jimjjewett at gmail.com
Mon Mar 13 20:47:19 CET 2006


Paul Moore wrote:

> Is there any practical way of detecting and flagging
> constructs like the above (remotely shadowing a
> builtin in another module)?

Phillip J. Eby wrote:
> the patch ended up being backed out ... too strict
> of a check to be accepted for Python 2.4.

http://svn.python.org/view/python/trunk/Objects/moduleobject.c

It was revision 33054, backed out in 33084.

The patch warned about any shadowing of builtins, which
probably is too strict.  An alternative might be to warn
only about modifying *another* module's globals.  (And
perhaps not just when they shadow builtins?)

For example, modules could grow a __sealed__ attribute
which gets set at the end of the import; instead of using
PyObject_GenericSetAttr directly, the tp_setattro slot
would check the __sealed__ attribute (and maybe squawk)
before deferring.

-jJ


More information about the Python-Dev mailing list