-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
Description
Issue
- We have a lot of
__init__.pyfiles which aggregate imports. This causes us to waste time importing things we don't need. Jeff has merged a solution to this ( Import Fix & Optimize: G1 without ROS, lazy imports, Fix bad dir naming, DIM-457, DIM-458, DIM-460, DIM-461 #1221 ), but I don't see why we need to bother re-exporting things to begin with. It's so much easier to import from the source. - What bugs me is that when we re-export, we end up with two (or more) paths from which we can import the same thing. The codebase has this a lot.
- You always have to double check what you're importing. This occurs when a re-export shadows a module with a function within it. For example imagine you have
def fooindimos/core/foo.py. You usefoo(…)in your code and you have to import it. Which import do you add?from dimos.core import fooorfrom dimos.core.foo import foo. The second is always reliable. But the first depends on whetherdimos/core/__init__.pyre-exportsdef foo. If it does not, thenfrom dimos.core import foois still valid, but it's not the function, it's the module. Allowing re-exports leads to uncertainty. - If the worry is that removing them creates long imports for users, then there is a solution for this. We can create a single file of lazy imports at the root defining our entire public API. But internally, we should just import things from where they are defined.
Synced from DIM-534
Reactions are currently unavailable