Skip to content

Commit

Permalink
Don't memoize EffectCollection.top_priority_effect()
Browse files Browse the repository at this point in the history
Closes #131

Also a trivial performance improvement for object equality in Collection and Variant when the objects being compared are the same object.
  • Loading branch information
timodonnell committed Dec 14, 2015
1 parent 48cd5ea commit 71d1f08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions varcode/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def __getitem__(self, idx):
return self.elements[idx]

def __eq__(self, other):
if self is other:
return True
return (
self.__class__ == other.__class__ and
len(self) == len(other) and
Expand Down
1 change: 0 additions & 1 deletion varcode/effect_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def detailed_string(self):
lines.append(" Highest Priority Effect: %s" % best)
return "\n".join(lines)

@memoize
def top_priority_effect(self):
"""Highest priority MutationEffect of all genes/transcripts overlapped
by this variant. If this variant doesn't overlap anything, then this
Expand Down
2 changes: 2 additions & 0 deletions varcode/variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def fields(self):
self.ensembl.release)

def __eq__(self, other):
if self is other:
return True
return (
self.contig == other.contig and
self.start == other.start and
Expand Down

0 comments on commit 71d1f08

Please sign in to comment.