From 2fde657222899e351a126bda26dc39b586140544 Mon Sep 17 00:00:00 2001 From: Dave Gadling Date: Mon, 6 Oct 2014 11:16:14 -0700 Subject: [PATCH] ParseResource's need to know they've been loaded In __getattr__ we check to see if the object has been lazy loaded or not before we try to do attribute lookups. However, once the attributes have been loaded, we never record that. So this changes _init_attrs, which actually does the loading, to record that it's done so. This change took a loop I had that was taking 8-10s to finish down to .5-1s. --- parse_rest/datatypes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/parse_rest/datatypes.py b/parse_rest/datatypes.py index 245a634..a6c1c8a 100644 --- a/parse_rest/datatypes.py +++ b/parse_rest/datatypes.py @@ -237,6 +237,7 @@ def __getattr__(self, attr): def _init_attrs(self, args): for key, value in six.iteritems(args): setattr(self, key, ParseType.convert_from_parse(value)) + self._is_loaded = True def _to_native(self): return ParseType.convert_to_parse(self)