Skip to content

Commit

Permalink
added comment explaining use of WeakValueDictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Sep 14, 2016
1 parent cc543a3 commit e99a0c5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyensembl/ensembl_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def normalize_init_values(cls, release, species, server):
species = check_species_object(species)
return (release, species, server)

# Using a WeakValueDictionary instead of an ordinary dict to prevent a
# memory leak in cases where we test many different releases in sequence.
# When all the references to a particular EnsemblRelease die then that
# genome should also be removed from this cache.
_genome_cache = WeakValueDictionary()

@classmethod
Expand Down

0 comments on commit e99a0c5

Please sign in to comment.