[Python-3000] Interest in PEP for callbacks on module import

Jim Jewett jimjjewett at gmail.com
Mon Dec 10 17:41:59 CET 2007


On 12/10/07, Christian Heimes <lists at cheimes.de> wrote:
> Jim Jewett wrote:
>  > I had thought that wouldn't be run until the module was otherwise
> > loaded.  Are you saying that just creating the callback forces a load
> > under lazy loading, but not under post-load hooks?

> I was saying that the problem can't be solved with lazy imports.

Let me rephrase.

You seem to be treating lazy imports and post-import hooks as two
independent binary choices, so that there are four logical
possibilities.

I don't see any point to supporting post-load hooks *without* lazy
importing, so to me, only three of those possibilities make sense.
(neither, lazy only, lazy+postimport)

Is there an example where you would use post-import hooks even though
the system didn't support lazy import?  The best I can come up with is
"Don't import module X just for me, but *if* someone else imports it,
then I want to do these things to/with it."

This still sounds like a (kind of) lazy import to me.  Are you
considering that not-even-a-lazy-import because you care about even
indirect usage?

-jJ


More information about the Python-3000 mailing list