Skip to content

Reorganize Hy internal imports #2132

@scauligi

Description

@scauligi

As noted in #2131, Hy ends up loading most of its internal modules just from the initial import of the top-level module.
Turns out it's not entirely trivial to fix this, since we have complicated dependency chains such as hy.importer._inject_builtins() needing hy.macros.load_macros(), but hy.macros imports hy.compiler (which itself imports macroexpand back from hy.macros...)

The whole thing is fragile enough that (naive) initial attempts just result in a bunch of ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import).

I think the proper solution for this is going to be a (potentially invasive?) reorganization so that dependencies are much clearer/saner and so that we actually get the benefit of just-in-time submodule loading.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions