Commit 7c7be184 authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Romain Courteaud

sql_catalog: Simplify LazyIndexationParameterList to improve performance

__getitem__ function for LazyIndexationParameterList eats up a lot of
performance. This patch tries to simplify the code to improve
performance.
parent 1174b7f2
...@@ -255,10 +255,9 @@ class LazyIndexationParameterList(tuple): ...@@ -255,10 +255,9 @@ class LazyIndexationParameterList(tuple):
document = self._document_list[index] document = self._document_list[index]
attribute = self._attribute attribute = self._attribute
global_cache_key = (document.uid, attribute) global_cache_key = (document.uid, attribute)
global_cache = self._global_cache try:
if global_cache_key in global_cache: value = self._global_cache[global_cache_key]
value = global_cache[global_cache_key] except KeyError:
else:
value = getattr(document, attribute, None) value = getattr(document, attribute, None)
if callable(value): if callable(value):
try: try:
...@@ -271,7 +270,7 @@ class LazyIndexationParameterList(tuple): ...@@ -271,7 +270,7 @@ class LazyIndexationParameterList(tuple):
error=True, error=True,
) )
value = None value = None
global_cache[global_cache_key] = value self._global_cache[global_cache_key] = value
return value return value
def __iter__(self): def __iter__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment