Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 22, 2012
@jtackaberry jtackaberry At bitwise OR and AND operators to _LazyProxy 77c49fe
@jtackaberry jtackaberry Lazy-load the other object for binary operators if it's also a _LazyP…
…roxy
19192c4
@jtackaberry jtackaberry Make __nonzero__ return True/False rather than 1/0
2to3 changes __nonzero__ to __bool__ but does not change the return
values.  Python 3 requires __bool__ to return either True or False.
4dd32e2
Showing with 21 additions and 2 deletions.
  1. +19 −0 src/__init__.py
  2. +2 −2 src/weakref.py
View
19 src/__init__.py
@@ -158,6 +158,9 @@ class _LazyProxy(type):
# imports core (setattr hook)
>>> import kaa
>>> kaa.Signal.MAX_CONNECTIONS = 10000
+
+ # imports io (bitwise operator hook)
+ >>> kaa.IO_READ | kaa.IO_WRITE
"""
def __new__(cls, name, bases, dict):
if bases == (_object,):
@@ -272,29 +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)
View
4 src/weakref.py
@@ -95,9 +95,9 @@ def __setitem__(self, key, value):
def __nonzero__(self):
if self._ref():
- return 1
+ return True
else:
- return 0
+ return False
def __cmp__(self, other):
if type(other) == weakref:

No commit comments for this range

Something went wrong with that request. Please try again.