From 9d094b68f370a413a6cb319737dcadd06aada1af Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 14 Dec 2017 22:23:59 +0100 Subject: [PATCH] Cache the subprocess results --- jedi/evaluate/compiled/subprocess/__init__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/compiled/subprocess/__init__.py b/jedi/evaluate/compiled/subprocess/__init__.py index d9100895..37e3f250 100644 --- a/jedi/evaluate/compiled/subprocess/__init__.py +++ b/jedi/evaluate/compiled/subprocess/__init__.py @@ -275,6 +275,18 @@ class AccessHandle(object): #print >> sys.stderr, name #print('getattr', name, file=sys.stderr) - def compiled_method(*args, **kwargs): + return partial(self._workaround, name) + + def _workaround(self, name, *args, **kwargs): + """ + TODO Currently we're passing slice objects around. This should not + happen. They are also the only unhashable objects that we're passing + around. + """ + if args and isinstance(args[0], slice): return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs) - return compiled_method + return self._cached_results(name, *args, **kwargs) + + @memoize_method + def _cached_results(self, name, *args, **kwargs): + return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs)