当前位置: 首页>>代码示例>>Python>>正文


Python passmanager.Transformation类代码示例

本文整理汇总了Python中pythran.passmanager.Transformation的典型用法代码示例。如果您正苦于以下问题:Python Transformation类的具体用法?Python Transformation怎么用?Python Transformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Transformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generic_visit

 def generic_visit(self, node):
     if node in self.constant_expressions:
         try:
             fake_node = ast.Expression(node.value if isinstance(node, ast.Index) else node)
             code = compile(fake_node, "<constant folding>", "eval")
             value = eval(code, self.env)
             new_node = self.to_ast(value)
             if isinstance(node, ast.Index) and not isinstance(new_node, ast.Index):
                 new_node = ast.Index(new_node)
             return new_node
         except ConstantFolding.ConversionError as e:
             print ast.dump(node)
             print "error in constant folding: ", e
             raise
         except ConstantFolding.ToNotEval:
             return Transformation.generic_visit(self, node)
         except AttributeError as e:
             # FIXME union_ function is not handle by constant folding
             if "union_" in e.args[0]:
                 return Transformation.generic_visit(self, node)
             raise
         except NameError as e:
             # FIXME dispatched function are not processed by constant
             # folding
             if "__dispatch__" in e.args[0]:
                 return Transformation.generic_visit(self, node)
             raise
     else:
         return Transformation.generic_visit(self, node)
开发者ID:baoboa,项目名称:pythran,代码行数:29,代码来源:constant_folding.py

示例2: __init__

 def __init__(self, pm, name, ctx, lambda_functions, imports):
     Transformation.__init__(self)
     self.passmanager = pm
     self.ctx = ctx
     self.prefix = name
     self.lambda_functions = lambda_functions
     self.imports = imports
     self.global_declarations = pm.gather(GlobalDeclarations, ctx.module)
开发者ID:baoboa,项目名称:pythran,代码行数:8,代码来源:remove_lambdas.py

示例3: generic_visit

 def generic_visit(self, node):
     if node in self.constant_expressions:
         try:
             fake_node = ast.Expression(
                 node.value if isinstance(node, ast.Index) else node)
             code = compile(fake_node, '<constant folding>', 'eval')
             value = eval(code, self.env)
             new_node = self.to_ast(value)
             if (isinstance(node, ast.Index)
                     and not isinstance(new_node, ast.Index)):
                 new_node = ast.Index(new_node)
             return new_node
         except Exception:  # as e:
             #print ast.dump(node)
             #print 'error in constant folding: ', e
             return Transformation.generic_visit(self, node)
     else:
         return Transformation.generic_visit(self, node)
开发者ID:biznixcn,项目名称:pythran,代码行数:18,代码来源:constant_folding.py

示例4: generic_visit

 def generic_visit(self, node):
     if node in self.constant_expressions:
         try:
             fake_node = ast.Expression(
                 node.value if isinstance(node, ast.Index) else node)
             code = compile(fake_node, '<constant folding>', 'eval')
             value = eval(code, self.env)
             new_node = to_ast(value)
             if(isinstance(node, ast.Index) and
                not isinstance(new_node, ast.Index)):
                 new_node = ast.Index(new_node)
             try:
                 if not ASTMatcher(node).search(new_node):
                     self.update = True
             except DamnTooLongPattern as e:
                 print "W: ", e, " Assume no update happened."
             return new_node
         except ConversionError as e:
             print ast.dump(node)
             print 'error in constant folding: ', e
             raise
         except ToNotEval:
             return Transformation.generic_visit(self, node)
         except AttributeError as e:
             # FIXME union_ function is not handle by constant folding
             if "union_" in e.args[0]:
                 return Transformation.generic_visit(self, node)
             elif "pythran" in e.args[0]:
                 # FIXME: Can be fix giving a Python implementation for
                 # these functions.
                 return Transformation.generic_visit(self, node)
             raise
         except NameError as e:
             # FIXME dispatched function are not processed by constant
             # folding
             if "__dispatch__" in e.args[0]:
                 return Transformation.generic_visit(self, node)
             raise
     else:
         return Transformation.generic_visit(self, node)
开发者ID:Pikalchemist,项目名称:pythran,代码行数:40,代码来源:constant_folding.py

示例5: __init__

 def __init__(self):
     Transformation.__init__(self, NormalizeTuples,
                             OptimizableComprehension)
开发者ID:Pikalchemist,项目名称:pythran,代码行数:3,代码来源:list_comp_to_map.py

示例6: __init__

 def __init__(self):
     self.count = 0
     Transformation.__init__(self)
开发者ID:xmar,项目名称:pythran,代码行数:3,代码来源:remove_comprehension.py

示例7: __init__

 def __init__(self):
     Transformation.__init__(self, RangeValues)
开发者ID:serge-sans-paille,项目名称:pythran,代码行数:2,代码来源:range_based_simplify.py

示例8: __init__

 def __init__(self):
     Transformation.__init__(self, Globals)
     self.imports = {'__builtin__': '__builtin__'}
     self.to_import = set()
开发者ID:serge-sans-paille,项目名称:pythran,代码行数:4,代码来源:normalize_method_calls.py

示例9: __init__

 def __init__(self):
     Transformation.__init__(self, ConstantExpressions)
开发者ID:serge-sans-paille,项目名称:pythran,代码行数:2,代码来源:constant_folding.py

示例10: __init__

 def __init__(self):
     Transformation.__init__(self, PotentialIterator, Aliases)
开发者ID:pythran-travis,项目名称:pythran,代码行数:2,代码来源:iter_transformation.py

示例11: __init__

 def __init__(self):
     Transformation.__init__(self, NormalizeTuples,
                             PotentialIterator)
开发者ID:xmar,项目名称:pythran,代码行数:3,代码来源:list_comp_to_genexp.py

示例12: __init__

 def __init__(self):
     """ Gather required information. """
     Transformation.__init__(self, PotentialIterator, Aliases)
开发者ID:LuisBL,项目名称:pythran,代码行数:3,代码来源:iter_transformation.py

示例13: __init__

 def __init__(self):
     Transformation.__init__(self, TypeDependencies,
                             OrderedGlobalDeclarations)
开发者ID:pythran-travis,项目名称:pythran,代码行数:3,代码来源:typing.py

示例14: __init__

 def __init__(self):
     Transformation.__init__(self, Identifiers)
开发者ID:xmar,项目名称:pythran,代码行数:2,代码来源:unshadow_parameters.py

示例15: __init__

 def __init__(self):
     Transformation.__init__(self, UseDefChains, Ancestors, Aliases,
                             RangeValues, Identifiers)
     self.loops_mod = dict()
开发者ID:serge-sans-paille,项目名称:pythran,代码行数:4,代码来源:modindex.py


注:本文中的pythran.passmanager.Transformation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。