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

Represent Alphabet symbols as tuple to improve performance #629

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

padix-key
Copy link
Member

Although an Alphabet is immutable the base Alphabet class stores symbols in a list. To ensure immutability Alphabet.get_symbols() copies the internal list of symbols. In some scenarios this massively reduces the performance as some other methid, such as __len__() also call get_symbols().

This PR improves performance by storing the symbols in a tuple instead of a list. This also conveys the message of immutability better.

@padix-key padix-key force-pushed the alphabet branch 4 times, most recently from dd2061a to 82eba31 Compare July 23, 2024 13:38
@padix-key padix-key merged commit fa6724b into biotite-dev:next-major-release Jul 23, 2024
21 checks passed
@padix-key padix-key deleted the alphabet branch August 20, 2024 12:17
padix-key added a commit that referenced this pull request Aug 20, 2024
* Fix typo in docstring

* Fix formatting

* Support hashing

* Represent symbols as tuple to improve performance
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