Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: remove module level AutoWorld import from BaseClasses #2790

Merged

Conversation

black-sliver
Copy link
Member

@black-sliver black-sliver commented Feb 3, 2024

What is this fixing or adding?

With BaseClasses running worlds/__init__.py and worlds importing from BaseClasses, this is likely to result in some extra code being run because of partial recursive imports. This now lazily loads worlds when needed, at which point sys.modules should be properly populated.

Total time to run python test/benchmark/load_worlds.py is 50-100ms faster for me with this change, but that might be a fluke (noise level is pretty high).

How was this tested?

Unit tests

Rolling a simple item_link and looking at the spoiler to see the link was created.

With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads worlds when
needed at which point `sys.modules` should be properly populated.
@ScipioWright ScipioWright added the affects: core Issues/PRs that touch core and may need additional validation. label Feb 3, 2024
@agilbert1412
Copy link
Collaborator

@Berserker66 If you approved this PR and it's passing all automation, why not merge it?

@black-sliver
Copy link
Member Author

black-sliver commented Feb 14, 2024

Typically, if the author has write permissions, it does not hurt to let the author (decide when to) merge. I actually did wait for something else so that's why I didn't press the button immediately (and then I forgot).

@black-sliver black-sliver merged commit e5980ac into ArchipelagoMW:main Feb 14, 2024
12 checks passed
@black-sliver black-sliver deleted the baseclasses-lazy-import branch February 14, 2024 21:56
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads `worlds` when
needed, at which point `sys.modules` should be properly populated.
TheLX5 pushed a commit to TheLX5/Archipelago that referenced this pull request Mar 2, 2024
With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads `worlds` when
needed, at which point `sys.modules` should be properly populated.
TheLX5 pushed a commit to TheLX5/Archipelago that referenced this pull request Mar 2, 2024
With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads `worlds` when
needed, at which point `sys.modules` should be properly populated.
EmilyV99 pushed a commit to EmilyV99/Archipelago that referenced this pull request Apr 15, 2024
With BaseClasses running `worlds.__init__.py` and worlds importing
`from BaseClasses`, this is likely to result in some extra code being run
because of partial recursive imports. This now lazily loads `worlds` when
needed, at which point `sys.modules` should be properly populated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants