diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2013-08-02 16:36:05 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-08-07 13:59:32 +0900 |
commit | 5e703c7f09cacee75b91d6b219d3b8904f635c80 (patch) | |
tree | 2be9366d642900047a9953ec1bb999df40d8baa1 | |
parent | 4fd61eb8c5c52d9cc0430022ea702c331f16b254 (diff) |
ofproto: _baseattribute can be class attribute
So that it can save memory a bit.
Cc: yamamoto@valinux.co.jp
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_parser.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py index 8cb04024..bfb9866f 100644 --- a/ryu/ofproto/ofproto_parser.py +++ b/ryu/ofproto/ofproto_parser.py @@ -58,7 +58,11 @@ def create_list_of_base_attributes(f): @functools.wraps(f) def wrapper(self, *args, **kwargs): ret = f(self, *args, **kwargs) - self._base_attributes = set(dir(self)) + cls = self.__class__ + # hasattr(cls, '_base_attributes') doesn't work because super class + # may already have the attribute. + if '_base_attributes' not in cls.__dict__: + cls._base_attributes = set(dir(self)) return ret return wrapper |