summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2015-04-18 07:07:47 -0700
committerEli Bendersky <eliben@gmail.com>2015-04-18 07:07:47 -0700
commite6a05f833774daedf4267d5aa7625b0cc9eab33c (patch)
tree374ed4ab0d7022efd5b8f03b8ae3c1fb77ca0fb9
parent0874412e612cb327c1452afc8375aed7a18c7531 (diff)
downloadpycparser-e6a05f833774daedf4267d5aa7625b0cc9eab33c.tar.gz
Add __slots__ to the Coord class.
This further reduces memory usage for large inputs (#72)
-rw-r--r--pycparser/plyparser.py1
-rw-r--r--z.py8
2 files changed, 6 insertions, 3 deletions
diff --git a/pycparser/plyparser.py b/pycparser/plyparser.py
index cf327ab..c945f09 100644
--- a/pycparser/plyparser.py
+++ b/pycparser/plyparser.py
@@ -15,6 +15,7 @@ class Coord(object):
- Line number
- (optional) column number, for the Lexer
"""
+ __slots__ = ('file', 'line', 'column')
def __init__(self, file, line, column=None):
self.file = file
self.line = line
diff --git a/z.py b/z.py
index 33cbf4d..5b25120 100644
--- a/z.py
+++ b/z.py
@@ -76,6 +76,8 @@ class NodeVisitor(object):
def heapyprofile():
+ # pip install guppy
+ # [works on python 2.7, AFAIK]
from guppy import hpy
import gc
@@ -83,7 +85,7 @@ def heapyprofile():
ast = parse_file('/tmp/197.c')
gc.collect()
h = hp.heap()
- print h
+ print(h)
def memprofile():
@@ -109,8 +111,8 @@ if __name__ == "__main__":
}
'''
- #memprofile()
- heapyprofile()
+ memprofile()
+ #heapyprofile()
#parser = CParser()
#ast = parser.parse(source_code, filename='zz')