[Python-Dev] Draft PEP: "Simplified Package Layout and Partitioning"

P.J. Eby pje at telecommunity.com
Thu Jul 21 23:12:41 CEST 2011


At 12:59 PM 7/21/2011 -0700, Reliable Domains wrote:
>I assume that the implicit extend_virtual_paths() would be smart 
>enough to only do real work if there are virtual packages to do it 
>in, so much of the performance costs (bunch of stats) are bounded by 
>the existence of and number of virtual packages that have actually 
>been imported, correct?

Yes - this is true even for an explicit call.  It only does this for 
imported virtual packages, and child virtual packages are only 
checked for if the parent package exists.  So, in the case of a 
directory being added that has no parent packages, then the cost in 
stats is equal to the number of top-level, *imported* virtual packages.

The __path__ wrapper scheme can do this even better, and defer doing 
any of the stat calls until/unless another import occurs for one of 
those packages.  So if you munge sys.path and then don't import 
anything from a virtual package, no extra stat calls would happen at all.



More information about the Python-Dev mailing list