[Python-Dev] Making builtins more efficient

Josiah Carlson jcarlson at uci.edu
Thu Mar 9 19:16:54 CET 2006


Steven Elliott <selliott4 at austin.rr.com> wrote:
> I'm interested in how builtins could be more efficient.  I've read over
> some of the PEPs having to do with making global variables more
> efficient (search for "global"):
>     http://www.python.org/doc/essays/pepparade.html
> But I think the problem can be simplified by focusing strictly on
> builtins.


Whether or not it is a good idea, it is not wholly uncommon for users to
manipulate variables in the builtin or other module namespaces.  From
very simple import hooks replacing __import__, to module.QUIT = 1, these
things happen, and I don't think that making them produce a warning as
suggested by Paul, necessarily helps us.

I personally think the problem can be simplified (and solved) by
applying decorators where such builtin lookups could/should be more
efficient.  Raymond has a recipe for doing such optimization over at the
Python cookbook:
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940

Toss that little guy into a decorators module; if people want their
runtime calling to be fast (at the expense of a slightly increased
compilation time), they'll start using it.

 - Josiah



More information about the Python-Dev mailing list