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

Speed up and despam CLI startup #462

Merged
merged 1 commit into from
Jul 19, 2023
Merged

Speed up and despam CLI startup #462

merged 1 commit into from
Jul 19, 2023

Conversation

rec
Copy link
Contributor

@rec rec commented Jul 19, 2023

Description

Tiny annoyance removed.

Starting up the superduperdb cli with e.g. python -m superduperdb --help took three seconds and generated six lines of irrelevant output.

These two tiny changes reduced it to 0.3 seconds and no output.

@rec rec requested a review from nenb July 19, 2023 09:24
Copy link
Contributor

@nenb nenb left a comment

Choose a reason for hiding this comment

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

Question for my education: What's the rationale for moving the imports inside the functions?

@rec
Copy link
Contributor Author

rec commented Jul 19, 2023

@nenb: Good question, it turns out to be a useful technique.

If the import is at the top of the file, then it happens immediately when the file is loaded, including any side effects like loading large libraries that different things.

If the import is in code, it happens the first time you execute that code, and then never again.

All else being equal, imports should be at the top of the file, so if there's a problem it gets detected early as possible, but "not wanting to import some large and irrelevant module" is a perfectly good reason to perform local imports. :-)

@rec rec merged commit 7ccb9d5 into superduper-io:main Jul 19, 2023
@rec rec deleted the faiss branch July 19, 2023 10:31
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