[gobject-introspection] giscanner: define __slots__ on some classes



commit d736c075cd697fe38e0d7836d127c8bd7d884ada
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Wed May 15 08:03:57 2013 +0200

    giscanner: define __slots__ on some classes
    
    For example, when creating Gtk-3.0.gir, thousands of instances
    of these classes get created. This makes us waste less space
    for these instances by not having their __dict__ being created.

 giscanner/annotationparser.py |    9 +++++++++
 giscanner/message.py          |    3 +++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 33137c1..b8e86e9 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -449,6 +449,8 @@ MULTILINE_ANNOTATION_CONTINUATION_RE = re.compile(
 
 class DocBlock(object):
 
+    __slots__ = ('name', 'annotations', 'value', 'tags', 'description', 'params', 'position')
+
     def __init__(self, name):
         self.name = name
         self.annotations = DocAnnotations()
@@ -508,6 +510,8 @@ class DocBlock(object):
 
 class DocTag(object):
 
+    __slots__ = ('block', 'name', 'annotations', 'description', 'value', 'position')
+
     def __init__(self, block, name):
         self.block = block
         self.name = name
@@ -685,6 +689,9 @@ class DocTag(object):
 
 
 class DocAnnotations(object):
+
+    __slots__ = ('values', 'position')
+
     def __init__(self):
         self.values = []
         self.position = None
@@ -724,6 +731,8 @@ class DocAnnotations(object):
 
 class DocOption(object):
 
+    __slots__ = ('tag', '_array', '_dict')
+
     def __init__(self, tag, option):
         self.tag = tag
         self._array = []
diff --git a/giscanner/message.py b/giscanner/message.py
index 3a330af..fc6100e 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -34,6 +34,9 @@ class Position(object):
     """Represents a position in the source file which we
     want to inform about.
     """
+
+    __slots__ = ('filename', 'line', 'column')
+
     def __init__(self, filename=None, line=None, column=None):
         self.filename = filename
         self.line = line


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]