From 71d1f08dafa1497d94b0eb8bff31c9134e8080c7 Mon Sep 17 00:00:00 2001 From: Tim O'Donnell Date: Mon, 14 Dec 2015 11:35:04 -0500 Subject: [PATCH] Don't memoize EffectCollection.top_priority_effect() Closes #131 Also a trivial performance improvement for object equality in Collection and Variant when the objects being compared are the same object. --- varcode/collection.py | 2 ++ varcode/effect_collection.py | 1 - varcode/variant.py | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/varcode/collection.py b/varcode/collection.py index 47b622c..854ec32 100644 --- a/varcode/collection.py +++ b/varcode/collection.py @@ -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 diff --git a/varcode/effect_collection.py b/varcode/effect_collection.py index b413926..b1f3ad7 100644 --- a/varcode/effect_collection.py +++ b/varcode/effect_collection.py @@ -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 diff --git a/varcode/variant.py b/varcode/variant.py index 8b7f65f..d87f980 100644 --- a/varcode/variant.py +++ b/varcode/variant.py @@ -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