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

Move builtin loading code entirely out of __init__ #879

Merged
merged 2 commits into from
Jul 15, 2023

Conversation

rocky
Copy link
Member

@rocky rocky commented Jul 15, 2023

... YAY!

This paves the way for further improvements.

... YAY!

This paves the way for further improvements.
@rocky rocky requested a review from mmatera July 15, 2023 17:43
@rocky rocky marked this pull request as draft July 15, 2023 17:44
@@ -5,4 +5,4 @@
# well as importing into Python. That's why there is no
# space around "=" below.
# fmt: off
__version__="6.0.2dev0" # noqa
__version__="6.1.0dev0" # noqa
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be 7.0.0. Even before this change there were a number of API breaking changes. You'll see them in the recent Mathics3 Modules (natlang, and graph). And we'll have to change these more for this as well.


# List of Mathics3 Builtin modules.
# This is initialized via below import_builtins modules
modules = []
Copy link
Member Author

@rocky rocky Jul 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"modules" is a too vague a name. Probably mathics3_builtin_modules is better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

from mathics.core.parser import MathicsFileLineFeeder, MathicsLineFeeder
from mathics.core.read import channel_to_stream
from mathics.core.rules import BuiltinRule
from mathics.core.streams import stream_manager
from mathics.core.symbols import SymbolNull, strip_context
from mathics.timing import show_lru_cache_statistics

import_and_load_builtins()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this section is isolated we could and should be able to time how long running this subroutine takes.

Copy link
Contributor

@mmatera mmatera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes look good. Merge this when you feel it is ready.

* module -> mathics3_builtins_modules
* Bump version to 7.0.0dev0
* More type annotations
* Add in comments debug code to time loading builtin functions

I see 2.2secs out of 7 secs to run: mathics -e "1+1"
@rocky rocky marked this pull request as ready for review July 15, 2023 22:59
@rocky
Copy link
Member Author

rocky commented Jul 15, 2023

running mathics -e '1+1' with the timing decorator around loading builtin modules show that 2.2 seconds out of 7 elapsed are spent in loading.

Next changes will be to be able to load builtin modules one at a time rather than as a set of sequential loops which do phases of module loading.

@rocky rocky merged commit 111c92b into master Jul 15, 2023
11 checks passed
@rocky rocky deleted the move-builtin-load-init branch July 15, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants