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
This commit is contained in:
parent
e7a7f60631
commit
67d58bc17f
@ -67,7 +67,9 @@ def _setup_context(data, context, finalizer, convention):
|
||||
@specs.inject('engine', yaqltypes.Engine())
|
||||
@specs.name('#finalize')
|
||||
def finalize(obj, limiter, engine):
|
||||
if engine.options.get('yaql.convertOutputData', True):
|
||||
return utils.convert_output_data(obj, limiter, engine)
|
||||
return obj
|
||||
|
||||
context.register_function(limit)
|
||||
context.register_function(finalize)
|
||||
|
@ -161,7 +161,10 @@ class Statement(Function):
|
||||
if context is None or context is utils.NO_VALUE:
|
||||
context = yaql.create_context()
|
||||
if data is not utils.NO_VALUE:
|
||||
if self.engine.options.get('yaql.convertInputData', True):
|
||||
context['$'] = utils.convert_input_data(data)
|
||||
else:
|
||||
context['$'] = data
|
||||
return self(utils.NO_VALUE, context, self.engine)
|
||||
|
||||
def __str__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user