Skip to content

Look up each module name without a package version only once - #767

Merged
hansott merged 5 commits into
mainfrom
fix/cache-package-lookup-misses
Oct 27, 2026
Merged

hansott merged 5 commits into
mainfrom
fix/cache-package-lookup-misses

Conversation

@iacobdaniel

Copy link
Copy Markdown
Contributor

Zen looks up the version of each imported package, but for names with no installed package (re, json, yaml) it found nothing and searched all of sys.path again on every import, about 50–70 µs each time. This remembers those names so each one is searched only once per process.

Comment thread aikido_zen/sinks/builtins_import.py Outdated
Comment thread aikido_zen/background_process/packages.py Outdated
def import_list(imported_packages):
for package in imported_packages:
if PackagesStore.get_package(package["name"]):
if package["name"] in packages_store:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The direct packages_store check in import_list is an unrelated rewrite of the existing get_package lookup and is not needed for miss caching.

Details

✨ AI Reasoning
​The intended behavioral change is to remember names whose version lookup fails. The direct dictionary membership check in import_list does not implement that behavior; it replaces an existing lookup with equivalent internal access. That separate rewrite can be omitted while preserving the new miss-cache behavior.

🔧 How do I fix it?
Limit the change to what's needed to achieve its intent. Avoid bundling unrelated reformatting or refactoring, and don't rewrite code that didn't need to change.

Reply on this comment to give feedback or ignore the issue.
More info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intentional, for consistency: add_installed_package now checks packages_store directly, so import_list does the same. Behaviour is unchanged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⛔ You don't have permission to ignore issues.

@hansott
hansott merged commit c21635d into main Oct 27, 2026
227 of 250 checks passed
@hansott
hansott deleted the fix/cache-package-lookup-misses branch October 27, 2026 09:45
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.

3 participants