diff --git a/lark/lexer.py b/lark/lexer.py index bcf09f1..0a46ee1 100644 --- a/lark/lexer.py +++ b/lark/lexer.py @@ -25,6 +25,8 @@ class UnexpectedInput(LexError): self.considered_rules = considered_rules class Token(Str): + __slots__ = ('type', 'pos_in_stream', 'value', 'line', 'column', 'end_line', 'end_column') + def __new__(cls, type_, value, pos_in_stream=None, line=None, column=None): self = super(Token, cls).__new__(cls, value) self.type = type_ diff --git a/lark/parsers/grammar_analysis.py b/lark/parsers/grammar_analysis.py index 9ad49ce..5cbd697 100644 --- a/lark/parsers/grammar_analysis.py +++ b/lark/parsers/grammar_analysis.py @@ -5,6 +5,8 @@ from ..grammar import Rule class RulePtr(object): + __slots__ = ('rule', 'index') + def __init__(self, rule, index): assert isinstance(rule, Rule) assert index <= len(rule.expansion)