Lazy-load restriction enzyme data#29
Closed
richarda23 wants to merge 2 commits into
Closed
Conversation
… 3.9 - Add return type annotations to all provider methods missing them - Replace tautological assertions in test_taxonomy with meaningful ones - Update pyproject.toml minimum Python version from 3.8 to 3.9 to match CI matrix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 437KB rest_dict was loaded at module level, meaning any import from faker_biology.mol_biol triggered the full parse. Now loaded on first use via a class-level cache on RestrictionEnzyme. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
from faker_biology.mol_biol.re import rest_dictimport, which was eagerly loading a 437KB / 21K-line dict on any import fromfaker_biology.mol_biol_rest_dict = Noneclass variable and_get_rest_dict()classmethod toRestrictionEnzyme— data is loaded at most once per process, on first useNonebefore first use and populated afterTest plan
test_rest_dict_not_loaded_until_first_use— confirms lazy-load behaviourtest_random_re,test_random_redata,test_min_size,test_blunt) continue to passpoetry run python -m pytest faker_biology/tests/— 35 passed🤖 Generated with Claude Code