Do more imported objects affect performance

Kirk Strauser kirk at daycos.com
Thu Dec 11 11:31:36 EST 2008


At 2008-12-01T11:30:44Z, Nick Craig-Wood <nick at craig-wood.com> writes:

> Importing the module is actualy slower...  If you import the name into
> your namespace then there is only one lookup to do.  If you import the
> module there are two.

Note that if you're importing the entire module but want to call a function
that many times, you can do something like:

    import timeit
    Timer = timeit.Timer
    for _ in xrange(1000000):
        Timer
-- 
Kirk Strauser
The Day Companies



More information about the Python-list mailing list