From 77559065be3f3e8a76d76e733c26bb9a149f7b42 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Tue, 22 Nov 2016 09:24:43 +0100 Subject: memory usage optimisations --- nodes.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nodes.py') diff --git a/nodes.py b/nodes.py index 214284a..b518513 100644 --- a/nodes.py +++ b/nodes.py @@ -4,6 +4,8 @@ from __future__ import print_function class Node(object): + __slots__ = 'tag', 'value', 'start_mark', 'end_mark', 'comment', 'anchor', + def __init__(self, tag, value, start_mark, end_mark, comment=None): self.tag = tag self.value = value @@ -62,6 +64,7 @@ class ScalarNode(Node): | -> literal style > -> folding style """ + __slots__ = 'style', id = 'scalar' def __init__(self, tag, value, start_mark=None, end_mark=None, style=None, @@ -71,6 +74,8 @@ class ScalarNode(Node): class CollectionNode(Node): + __slots__ = 'flow_style', 'anchor', + def __init__(self, tag, value, start_mark=None, end_mark=None, flow_style=None, comment=None, anchor=None): Node.__init__(self, tag, value, start_mark, end_mark, comment=comment) @@ -79,8 +84,10 @@ class CollectionNode(Node): class SequenceNode(CollectionNode): + __slots__ = () id = 'sequence' class MappingNode(CollectionNode): + __slots__ = () id = 'mapping' -- cgit v1.2.1