[Python-Dev] New Import Hooks PEP, a first draft (and req. for PEP #)

Neil Schemenauer nas@python.ca
Sat, 21 Dec 2002 18:25:52 -0800


Just van Rossum wrote:
>     This PEP proposes to add a new set of import hooks that offer better
>     customization of the Python import mechanism.  Contrary to the
>     current __import__ hook, a new-style hook can be injected into the
>     existing scheme, allowing for a finer grained control of how modules
>     are found and how they are loaded.

I only had time to skim this PEP.  Currently I am using import hooks to
load PTL modules (like .py modules but they have a different extension
and need a different compiler).  Most of the discussion has focused on
loading .py modules from places other than filesystems.  I was afraid my
use case would not get addressed (iu.py doesn't really work, ihooks.py
does).  It looks like the hooks proposed by this PEP are sufficent for
my needs.

This PEP addresses a real problem, IMHO.  The current __import__ hook is
hard to use.  There is too much complicated package import logic that
must be reimplemented.

  Neil