Skip to content

Conversation

@grden
Copy link
Contributor

@grden grden commented Sep 5, 2025

This computes tag index once, then stash it to wheel._best_tag_index.

Closes #160.

Comment on lines 416 to 419
tag_index = wheel._best_tag_index
if tag_index is None:
tag_index = best_compatible_tag_index(wheel.tags)
wheel._best_tag_index = tag_index
Copy link
Member

Choose a reason for hiding this comment

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

I think it is not a good idea to update the the private attribute of an object outside.

Instead, we can create a property in WheelInfo object such as

@property
def best_tag_index(self) -> float:
    if self._best_tag_index:
        return self._best_tag_index
    self._best_tag_index = best_compatible_tag_index(self.tags)
    return self._best_tag_index

Comment on lines 154 to 161
try:
tags = parse_tags(filename)
except (InvalidVersion, InvalidWheelFilename):
continue

tag_index = best_compatible_tag_index(tags)
if tag_index is None:
continue
Copy link
Member

Choose a reason for hiding this comment

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

Well, is_package_compatible does more than this.

I think we can keep the is_package_compatible call here, and update the signature of is_package_compatible to return the compatible tag as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thank you

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

Thanks!

@ryanking13 ryanking13 merged commit 65f4c2f into pyodide:main Sep 14, 2025
7 checks passed
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.

double best_compatible_tag_index call ?

2 participants