[Python-Dev] PEP 302 optional extensions only for loaders?

Brett Cannon brett at python.org
Thu Aug 23 22:38:36 CEST 2007


When you read PEP 302 and the section on the optional extensions, it
mentions that they "are highly recommended for general purpose
importers".  But then the PEP says very shortly thereafter that
"loader objects" are to have the extensions.

So which is it, importers or loaders?  The reason I ask is because if
one can assume that the extensions are only called on what find_module
returns, and thus extensions are only called on loaders, then some
caching can be done based on what find_module had to do.  In my case I
am reimplementing zipimport and if I can assume find_module was called
before is_package I can just cache in the object what module names
were found to be a package and then have is_package just be a lookup
in a set instead of having to read the zip file every time or store
all of the ZipInfo files for the zipfile.

-Brett


More information about the Python-Dev mailing list