summaryrefslogtreecommitdiff
path: root/compat.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-11-22 09:24:43 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-11-22 09:24:43 +0100
commit77559065be3f3e8a76d76e733c26bb9a149f7b42 (patch)
tree37bb94598d77b0eb879bb958c7dad76f7f51fc8f /compat.py
parenta72e8cf2f64855d29106f4f5b1687e09bcc9284e (diff)
downloadruamel.yaml-77559065be3f3e8a76d76e733c26bb9a149f7b42.tar.gz
memory usage optimisations0.13.1
Diffstat (limited to 'compat.py')
-rw-r--r--compat.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/compat.py b/compat.py
index 1cbe923..7a5ba06 100644
--- a/compat.py
+++ b/compat.py
@@ -101,6 +101,20 @@ DBG_NODE = 4
_debug = None
+if _debug:
+ class ObjectCounter(object):
+ def __init__(self):
+ self.map = {}
+
+ def __call__(self, k):
+ self.map[k] = self.map.get(k, 0) + 1
+
+ def dump(self):
+ for k in sorted(self.map):
+ print(k, '->', self.map[k])
+
+ object_counter = ObjectCounter()
+
# used from yaml util when testing
def dbg(val=None):