From 4ee7194809d31175074879d1b1a69ef5606eb32c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 17 Jun 2015 18:29:12 +0200 Subject: Add __slots__ to internal classes. Speeds _Feed creation up a bit during tokenization. Keep public classes slotless for flexibility. --- kconfiglib.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 27b8ac9..a6d1f5d 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3070,6 +3070,10 @@ class _Feed(object): """Class for working with sequences in a stream-like fashion; handy for tokens.""" + # This would be more helpful on the item classes, but would remove some + # flexibility + __slots__ = ['items', 'length', 'i'] + def __init__(self, items): self.items = items self.length = len(self.items) @@ -3106,6 +3110,8 @@ class _FileFeed(object): careful to get the line number right in the presence of continuation lines.""" + __slots__ = ['filename', 'lines', 'length', 'linenr'] + def __init__(self, filename): self.filename = _clean_up_path(filename) with open(filename, "r") as f: -- cgit v1.2.3