Skip to content

top-level imports are convenient, but they are slow #37

@tpchuckles

Description

@tpchuckles

commit 2ad51d1 enabled things like "from pyslice import MultisliceCalculator" instead of "from pyslice.multislice.calculators import MultisliceCalculator", because the user should not be expected to know the code structure / folder organization.

this was done by adding "from .multislice.calculators import *" and others to __init__.py

this means ALL imports occur when you do any import. where tests/00_probe.py used to only import multislice.multislice.Probe, taking a couple seconds, everything is now imported, taking up to 6 seconds.

@h-walk and I decided this is fine: okay to take a bit longer and make the code-writing experience better for the user

but if we wanted to address this, we could go through and move all the imports to inside the classes and functions (as recommended here). Then a simple import for the Probe will not import all the ase MD tools for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions