-
Notifications
You must be signed in to change notification settings - Fork 67
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
Deserialization should construct cached EnsemblRelease objects #163
Deserialization should construct cached EnsemblRelease objects #163
Conversation
…ctor for deserialization, added test for uniqueness of instances
It would be nice to do something similar for the |
the same EnsemblRelease object since each one will store a lot of cached | ||
annotation data in-memory. | ||
Keeping this function for backwards compatibility but this functionality | ||
has been moving onto the EnsemblRelease object itself by overriding __new__. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you overriding new?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that's left over from an old attempt (turned out too arcane).
if init_args_tuple in cls._genome_cache: | ||
genome = cls._genome_cache[init_args_tuple] | ||
else: | ||
genome = cls._genome_cache[init_args_tuple] = cls(*init_args_tuple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't even know this was valid syntax! It's right to left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, right to left (like Arabic!). It's a generalization of a = b = None
.
Agree that we need to generalize this, but good to have a solution for now! |
LGTM |
cached_release
onto the EnsemblRelease object (EnsemblRelease.cached
)WeakValueDictionary
instead of ordinary dict to avoid memory leakfrom_dict
class method to usecached
for deserializationThis change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)