[Dev] performance of prop vs. mod.prop

Jed Burgess jed at osafoundation.org
Thu Sep 9 19:13:54 PDT 2004


What about using:

import mod.prop as prop

# use prop in a tight loop

That is actually the convention we tend to use the most.

Jed


On Sep 9, 2004, at 7:03 PM, Heikki Toivonen wrote:

> Our coding guidelines state that we should import a whole module 
> rather than properties of the module. While this tends to make the 
> code more clear, there is a question about performance.
>
> In other words, is
>
> from mod import prop
>
> # use prop in tight loop
>
> different from
>
> import mod
>
> # use mod.prop in tight loop
>
> I finally decided to measure this, and my tests showed that the second 
> form (mod.prop) is over two times slower. It is still pretty fast, so 
> unless you are doing tens of thousands of iterations it probably does 
> not matter, if even then.
>
> -- 
>   Heikki Toivonen
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "Dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/dev




More information about the Dev mailing list