Skip to content

Commit 67d58bc

Browse files
author
Stan Lagun
committed
Added engine options to disable input/output data conversion
'yaql.convertInputData' and 'yaql.convertOutputData' engine options were added. By setting them to false one can suppress input or output data conversion. For the input data this will prevent yaql from converting mutable data structures (lists, dicts, sets) to their immutable versions, which will break some of the constructs that require hashable structures (for example set of lists, or list as a dictionary key), for the output it will not expand produced iterators and not convert tuples to lists. However this can greatly improve performance in some cases Change-Id: I240ce6646fe7dbc9522624739600b6c364bb9618
1 parent e7a7f60 commit 67d58bc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

yaql/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def limit(iterator):
6767
@specs.inject('engine', yaqltypes.Engine())
6868
@specs.name('#finalize')
6969
def finalize(obj, limiter, engine):
70-
return utils.convert_output_data(obj, limiter, engine)
70+
if engine.options.get('yaql.convertOutputData', True):
71+
return utils.convert_output_data(obj, limiter, engine)
72+
return obj
7173

7274
context.register_function(limit)
7375
context.register_function(finalize)

yaql/language/expressions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ def evaluate(self, data=utils.NO_VALUE, context=None):
161161
if context is None or context is utils.NO_VALUE:
162162
context = yaql.create_context()
163163
if data is not utils.NO_VALUE:
164-
context['$'] = utils.convert_input_data(data)
164+
if self.engine.options.get('yaql.convertInputData', True):
165+
context['$'] = utils.convert_input_data(data)
166+
else:
167+
context['$'] = data
165168
return self(utils.NO_VALUE, context, self.engine)
166169

167170
def __str__(self):

0 commit comments

Comments
 (0)