[issue17621] Create a lazy import loader mixin

Brett Cannon report at bugs.python.org
Tue Apr 2 20:00:47 CEST 2013


New submission from Brett Cannon:

People keep asking and I keep promising to get a lazy loader into Python 3.4. This issue is for me to track what I have done towards meeting that promise.

To start, I have something working at https://code.google.com/p/importers/, but I need to make sure that the code copies any newly assigned objects post-import but before completing an attribute read::

  import lazy_mod
  lazy_mod.attr = True  # Does not have to trigger import, although there is nothing wrong if it did.
  lazy_mod.func()  # Since it might depend on 'attr', don't return attr until after import and 'attr' with a value of True has been set.

Also need to see if anything can be done about isinstance/issubclass checks as super() is used for assigning to __loader__ and thus might break checks for ABCs. Maybe create a class from scratch w/o the mixin somehow (which I don't see from looking at http://docs.python.org/3.4/library/types.html#module-types w/o re-initializing everything)? Somehow get __subclasscheck__() on the super() class? Some other crazy solution that avoids having to call __init__() a second time?

----------
assignee: brett.cannon
components: Library (Lib)
messages: 185852
nosy: brett.cannon
priority: low
severity: normal
stage: test needed
status: open
title: Create a lazy import loader mixin
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17621>
_______________________________________


More information about the Python-bugs-list mailing list