Use __slots__ for tab.TabData

This commit is contained in:
Florian Bruhin 2016-07-07 19:36:27 +02:00
parent b999090a51
commit dde8ac6844

View File

@ -74,27 +74,18 @@ class TabData:
"""A simple namespace with a fixed set of attributes.
Attributes:
_initializing: Set when we're currently in __init__.
keep_icon: Whether the (e.g. cloned) icon should not be cleared on page
load.
inspector: The QWebInspector used for this webview.
viewing_source: Set if we're currently showing a source view.
"""
__slots__ = ['keep_icon', 'viewing_source', 'inspector']
def __init__(self):
self._initializing = True
self.keep_icon = False
self.viewing_source = False
self.inspector = None
self._initializing = False
def __setattr__(self, attr, value):
if (attr == '_initializing' or
getattr(self, '_initializing', False) or
hasattr(self, attr)):
return super().__setattr__(attr, value)
msg = "Can't set unknown attribute {!r}".format(attr)
raise AttributeError(msg)
class AbstractSearch(QObject):