[Python-3000] Interest in PEP for callbacks on module import
Nick Coghlan
ncoghlan at gmail.com
Sat Dec 8 06:56:19 CET 2007
Phillip J. Eby wrote:
>> > Does anyone else think this is an issue worth pursuing?
>
> A qualified yes: the Importing package took a long time to get correct
> under all the crazy little twists and turns of importing, including
> correctly handling things like the link between packages and their child
> packages/modules, the import order of same, race conditions, import
> locks, clearing out callbacks, etc. I'm somewhat hesitant as to whether
> a from-scratch reimplementation is wise.
I'm far from convinced that a from-scratch rewrite (particularly in C)
is a great idea myself - that's why I suggested a PEP to look at some of
the issues.
Some curly questions I thought of myself:
- What do we do if something is inserted in sys.modules directly, and
then imported later? Do registered callbacks for that module trigger at
all? If so, when?
- Does the lazy importing code need to reacquire the import lock before
loading the module on attribute access?
> There may be other interop issues with libraries that use ModuleType
> subclasses or do lazy import, deprecation, and similar module content
> manipulation, so a publicized PEP would be a good idea to get their
> developers' input.
Yeah, the more I think about it, the more I think a new PEP for lazy and
weak importing is the right way to go (although it would be nice if
using the latter didn't automatically cause the former). I'll put an
initial draft together (unless someone else beats me to it - I almost
certainly won't find time to do it until after Christmas)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list