Commit 9793b17b authored by Lars Buitinck's avatar Lars Buitinck

optimize: list(ob) -> PySequence_List(ob)

parent 1dead804
......@@ -2021,6 +2021,20 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
)
return node
PySequence_List_func_type = PyrexTypes.CFuncType(
Builtin.list_type,
[PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None)])
def _handle_simple_function_list(self, node, function, pos_args):
"""Turn list(ob) into PySequence_List(ob).
"""
if len(pos_args) != 1:
return node
arg = pos_args[0]
return ExprNodes.PythonCapiCallNode(
node.pos, "PySequence_List", self.PySequence_List_func_type,
args=pos_args, is_temp=node.is_temp)
PyList_AsTuple_func_type = PyrexTypes.CFuncType(
Builtin.tuple_type, [
PyrexTypes.CFuncTypeArg("list", Builtin.list_type, None)
......
......@@ -41,6 +41,18 @@ def k(obj1, obj2, obj3, obj4, obj5):
obj1 = [17, 42, 88]
return obj1
@cython.test_fail_if_path_exists("//SimpleCallNode")
def test_list_call(ob):
"""
>>> def f():
... yield 1
... yield 2
...
>>> list(f())
[1, 2]
"""
return list(ob)
def test_list_sort():
"""
>>> test_list_sort()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment