[Python-Dev] PEP: Post import hooks
Phillip J. Eby
pje at telecommunity.com
Fri Jan 11 00:10:08 CET 2008
At 11:45 PM 1/10/2008 +0100, Christian Heimes wrote:
>In my version a hook is immediately called when the the registry value
>is set to None. When a hook is registered for a module during the
>execution of the callback then the hook is fired directly and not after
>the existing hooks are called. Is this a problem for you?
Yes, because it violates the invariant that hooks for a given module
are called in the same order that they were registered in.
In case you're wondering why it's a problem, it's because if a hook
imports something that registers a hook, when previously that thing
wasn't imported until later, all of a sudden your callback order is
very different than what it was before.
More succinctly: if making small changes to your program can cause
large differences in the result, it's hard to debug. (Especially if
you have no idea what 3rd party module changed its import order and
messed things up.)
Believe me, it's a lot easier to debug if there is a globally
understandable hook order, even if it's still a partial ordering.
More information about the Python-Dev
mailing list