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

Avoid deserialization of PDBx data in __contains__() #679

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

padix-key
Copy link
Member

Currently the CIF and BinaryCIF container classes use the default mixin implementation of __contains__(). However, this default implementation uses

try:
    self[key]:
except KeyError:
    return False
return True

Hence, calling __contains__() actually gets the value, e.g. checking if a category name is in a CIF/BCIF block would automatically deserialize the category data. This counteracts the lazy deserialization behavior.

This PR explicitly implements __contains__() for all the mentioned container classes, checking only if a key is present and thus avoid the automatic deserialization.

@padix-key padix-key merged commit 53256ed into biotite-dev:main Oct 21, 2024
25 of 26 checks passed
@padix-key padix-key deleted the deserialize branch October 23, 2024 12:19
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.

1 participant