Permalink
Browse files

Lazy-load the other object for binary operators if it's also a _LazyP…

…roxy
  • Loading branch information...
1 parent 77c49fe commit 19192c4c884def3ead54dddc4769d3a0a12958c6 @jtackaberry jtackaberry committed Jan 22, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/__init__.py
View
@@ -275,35 +275,45 @@ def __dir__(cls):
return dir(cls.__get())
def __eq__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() == other
def __or__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() | other
def __and__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() & other
def __cmp__(cls, other):
# Python 2
+ other = other.__get() if type(other) == _LazyProxy else other
return cmp(cls.__get(), other)
# Python 3+
def __lt__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() < other
def __le__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() <= other
def __gt__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() > other
def __ge__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get() >= other
def __instancecheck__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get().__instancecheck__(other)
def __subclasscheck__(cls, other):
+ other = other.__get() if type(other) == _LazyProxy else other
return cls.__get().__subclasscheck__(other)

0 comments on commit 19192c4

Please sign in to comment.