[Python-ideas] Improve import mechanism for circular imports

Nick Coghlan ncoghlan at gmail.com
Tue Apr 10 15:45:04 CEST 2012


On Tue, Apr 10, 2012 at 9:57 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> Instead of giving a made-up example, if you describe what you are
> trying to achieve, I'm fairly certain someone here (or more likely on
> python-list) could show you a better way to do it, without needing
> circular imports.

There isn't actually a *strong* philosophical objection to improving
the circular import support. It's just a sufficiently hard problem
that the rote answer is "nobody has cared enough about the problem to
come up with a fix that works properly, is backwards compatible and
doesn't hurt the performance of regular imports".

The relevant tracker issue is http://bugs.python.org/issue992389 (yes,
that issue is approaching it's 8th birthday later this year)

With import.c going away soon (courtesy of the migration to importlib
as the main import implementation), it may become easier to devise a
solution (or at least generate a better error message).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list