From 5e703c7f09cacee75b91d6b219d3b8904f635c80 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 2 Aug 2013 16:36:05 +0900 Subject: [PATCH] ofproto: _baseattribute can be class attribute So that it can save memory a bit. Cc: yamamoto@valinux.co.jp Signed-off-by: Isaku Yamahata Signed-off-by: YAMAMOTO Takashi Signed-off-by: FUJITA Tomonori --- ryu/ofproto/ofproto_parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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