diff options
author | Michael Foord <michael@voidspace.org.uk> | 2011-10-29 23:54:32 +0100 |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2011-10-29 23:54:32 +0100 |
commit | 71ec1fb86bfc6ca90ddfd481d7e298014f0a6ae6 (patch) | |
tree | 0dd474750b8f5c22a694bf82efc192a72dc750f2 /mock.py | |
parent | 84b07a1efc95746f1c6295439f839b85a5d0911e (diff) | |
download | mock-71ec1fb86bfc6ca90ddfd481d7e298014f0a6ae6.tar.gz |
Micro optimisation
Diffstat (limited to 'mock.py')
-rw-r--r-- | mock.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1881,6 +1881,7 @@ class MagicProxy(object): def __get__(self, obj, _type=None): if obj is None: + # fetch the instance from a weak reference on its class obj = _type.__mock_instance__() return self.create_mock(obj) @@ -1941,9 +1942,10 @@ class _Call(tuple): name = '' args = () kwargs = {} - if len(value) == 3: + _len = len(value) + if _len == 3: name, args, kwargs = value - elif len(value) == 2: + elif _len == 2: first, second = value if isinstance(first, basestring): name = first @@ -1953,7 +1955,7 @@ class _Call(tuple): kwargs = second else: args, kwargs = first, second - elif len(value) == 1: + elif _len == 1: value, = value if isinstance(value, basestring): name = value |