class_docstr: Transforms list comprehension into intrinsics.
  >>> import gast as ast
  >>> from pythran import passmanager, backend
  >>> node = ast.parse("def foo(y) : return (x for x in y)")
  >>> pm = passmanager.PassManager("test")
  >>> _, node = pm.apply(ComprehensionPatterns, node)
  >>> 'map' in pm.dump(backend.Python, node)
  True
  
  >>> node = ast.parse("def foo(y) : return [0 for _ in builtins.range(y)]")
  >>> _, node = pm.apply(ComprehensionPatterns, node)
  >>> print(pm.dump(backend.Python, node))
  def foo(y):
      return ([0] * builtins.len(builtins.range(y)))
class_docstr_tok: ["Transforms","list","comprehension","into","intrinsics",".",">",">",">","import","gast","as","ast",">",">",">","from","pythran","import","passmanager",",","backend",">",">",">","node","=","ast.parse","(","``","def","foo","(","y",")",":","return","(","x","for","x","in","y",")","''",")",">",">",">","pm","=","passmanager.PassManager","(","``","test","''",")",">",">",">","_",",","node","=","pm.apply","(","ComprehensionPatterns",",","node",")",">",">",">","'map","'","in","pm.dump","(","backend.Python",",","node",")","True",">",">",">","node","=","ast.parse","(","``","def","foo","(","y",")",":","return","[","0","for","_","in","builtins.range","(","y",")","]","''",")",">",">",">","_",",","node","=","pm.apply","(","ComprehensionPatterns",",","node",")",">",">",">","print","(","pm.dump","(","backend.Python",",","node",")",")","def","foo","(","y",")",":","return","(","[","0","]","*","builtins.len","(","builtins.range","(","y",")",")",")"]
code: def visit_ListComp(self, node):
      def makeattr(*args):
          r = ast.Attribute(
              value=ast.Name(
                  id="builtins",
                  ctx=ast.Load(),
                  annotation=None,
                  type_comment=None,
              ),
              attr="map",
              ctx=ast.Load(),
          )
          r = ast.Call(r, list(args), [])
          r = ast.Call(
              ast.Attribute(
                  ast.Name("builtins", ast.Load(), None, None),
                  "list",
                  ast.Load(),
              ),
              [r],
              [],
          )
          return r
  
      if (
          isinstance(node.elt, ast.Constant)
          and len(node.generators) == 1
      ):
          gen = node.generators[0]
          if not gen.ifs and isinstance(gen.iter, ast.Call):
              try:
                  path = attr_to_path(gen.iter.func)[1]
                  range_path = (
                      "pythonic",
                      "builtins",
                      "functor",
                      "range",
                  )
                  if path == range_path and len(gen.iter.args) == 1:
                      self.update = True
                      return ast.BinOp(
                          ast.List([node.elt], ast.Load()),
                          ast.Mult(),
                          ast.Call(
                              path_to_attr(("builtins", "len")),
                              [gen.iter],
                              [],
                          ),
                      )
              except TypeError:
                  pass
  
      return self.visitComp(node, makeattr)
  
file_path: catboost/contrib/python/pythran/pythran/optimizations/comprehension_patterns.py
imports: from pythran.analyses import OptimizableComprehension
  from pythran.passmanager import Transformation
  from pythran.transformations.normalize_tuples import ConvertToTuple
  from pythran.conversion import mangle
  from pythran.utils import attr_to_path, path_to_attr
  import gast
label_desc: Use image node_id 5 for calling the ComprehensionPatterns obj's underlying member method code with example usage: obj.visit_ListComp(node) and returns: self, r, ast