[Python-3000] Interest in PEP for callbacks on module import
Jim Jewett
jimjjewett at gmail.com
Mon Dec 10 03:19:44 CET 2007
On 12/9/07, Christian Heimes <lists at cheimes.de> wrote:
> Jim Jewett wrote:
> > Could you give me a use-case for post-import hooks *without* lazy imports?
> This thread was started with perfect valid and good use case. We want to
> apply ABCs to classes of optional modules like decimal and array without
> loading the module or modifying the module.
>
> @imp.imported('decimal')
> def register(decimal):
> Inexact.register(decimal.Decimal)
>
> Lazy imports won't do the trick because the register could would load
> the real module. As you can see the problem can be solved with a post
> import hook but *not* with lazy imports.
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?
-jJ
More information about the Python-3000
mailing list