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

Check Python runtime version using tuple comparison instead of string parsing #208

Merged

Conversation

dgelessus
Copy link
Contributor

@dgelessus dgelessus commented Aug 18, 2020

Part of one of the potential fixes for kaitai-io/kaitai_struct#804. Depends on kaitai-io/kaitai_struct_python_runtime#49.

The previous implementation used pkg_resources.parse_version to parse
the kaitaistruct module's __version__ string. Unfortunately, importing
pkg_resources is relatively slow, which had a noticeable performance
impact on every ksc-generated parser.

The new implementation uses the newly added kaitaistruct.API_VERSION
attribute, which stores the runtime version as a tuple of ints. In this
format the version information can be compared directly without having
to parse it from a string first. This allows removing the import of
pkg_resources, which fixes the performance problem.

Part of the fix for kaitai-io/kaitai_struct#804.
Copy link
Member

@generalmimon generalmimon left a comment

Choose a reason for hiding this comment

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

@dgelessus Looks great, thanks! 💯

@generalmimon generalmimon merged commit 677a77b into kaitai-io:master Apr 9, 2022
@generalmimon
Copy link
Member

Well, I swear I knew a few minutes ago that I need to bump the versions by one (0.8->0.9 and 0.9->0.10) before merging this 😄, but no big deal, I'll do that right away.

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