From f9525965f9c0b09f0b95da0bf8924bb9b94fda23 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 22 Feb 2014 18:34:29 -0600 Subject: [PATCH] Add RecordWithoutPickling.register_fields --- pytools/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pytools/__init__.py b/pytools/__init__.py index f480c2c..17550f6 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -157,6 +157,14 @@ class RecordWithoutPickling(object): for fld in self.__class__.fields if hasattr(self, fld))) + def register_fields(self, new_fields): + try: + fields = self.__class__.fields + except AttributeError: + self.__class__.fields = fields = set() + + fields.update(new_fields) + class Record(RecordWithoutPickling): __slots__ = [] -- GitLab