[Python-Dev] towards a faster Python

Samuele Pedroni pedronis@bluewin.ch
Tue, 10 Jun 2003 16:03:06 +0200


At 09:51 10.06.2003 -0400, Guido van Rossum wrote:
> > 1. Extending builtins should still be possible like it is now.
> >
> >     Of course, the extensions wouldn't take part in the optimizations
> >     you have in mind, but they should still be found.
>
>I'm not sure what you mean by "extending builtins", but if it is what
>I think it is, I am strongly opposed.  The builtins should have fixed
>capabilities (in a particular Python version).  If you want a function
>that behaves just like a builtin but also can do something else, give
>it a different name and import it explicitly, don't override the
>existing entry in __builtin__.  If you have a new function that you
>want to use in lots of code, resist the temptation to add it to the
>__builtin__ module.  Zope did this e.g. with get_transaction() and the
>net result was reader confusion and intractable dependencies on import
>order.
>

what about substituing the built-in entirely for security reasons,
Zope3 does that with its wrapping versions:


     def ri_exec(self, code):
         # XXX What is the type of code?
         self.globals['__builtins__'] = RestrictedBuiltins
         exec code in self.globals

regards.