def to_tree(expr, names=None):
 if isinstance(expr, slice):
  return {u'op': u'slice', u'args': [to_tree(arg, names=names) for arg in [expr.start, expr.stop, expr.step]]}
 if (names and (expr in names)):
  return names[expr]
 if isinstance(expr, tuple):
  return [to_tree(arg, names=names) for arg in expr]
 if isinstance(expr, expr_utils._slice):
  return to_tree(expr.as_slice(), names=names)
 elif isinstance(expr, _Data):
  return to_tree(symbol(u8(expr._name), expr.dshape), names)
 elif isinstance(expr, Expr):
  return {u'op': u8(type(expr).__name__), u'args': [to_tree(arg, names) for arg in expr._args]}
 elif isinstance(expr, str):
  return u8(expr)
 else:
  return expr

def to_tree ( expr , names = None ) : if isinstance ( expr , slice ) : return { u'op' : u'slice' , u'args' : [ to_tree ( arg , names = names ) for arg in [ expr . start , expr . stop , expr . step ] ] } if ( names and ( expr in names ) ) : return names [ expr ] if isinstance ( expr , tuple ) : return [ to_tree ( arg , names = names ) for arg in expr ] if isinstance ( expr , expr_utils . _slice ) : return to_tree ( expr . as_slice ( ) , names = names ) elif isinstance ( expr , _Data ) : return to_tree ( symbol ( u8 ( expr . _name ) , expr . dshape ) , names ) elif isinstance ( expr , Expr ) : return { u'op' : u8 ( type ( expr ) . __name__ ) , u'args' : [ to_tree ( arg , names ) for arg in expr . _args ] } elif isinstance ( expr , str ) : return u8 ( expr ) else : return expr
represent blaze expression with core data structures transform a blaze expression into a form using only strings .