提交 d4140cdf authored 作者: Hengjean's avatar Hengjean

Added C interface for reverse

上级 6d426580
...@@ -318,6 +318,22 @@ class Reverse(Op): ...@@ -318,6 +318,22 @@ class Reverse(Op):
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
def c_code(self, node, name, inp, out, sub):
x_name = inp[0]
output_name = out[0]
if not self.inplace:
init = """
%(output_name)s = (PyListObject*) PyList_GetSlice((PyObject*) %(x_name)s, 0, PyList_GET_SIZE((PyObject*) %(x_name)s)) ;
""" % locals()
else:
init = """
%(output_name)s = %(x_name)s;
""" % locals()
return init + """
PyList_Reverse((PyObject*) %(output_name)s);
Py_INCREF(%(output_name)s);
""" % locals()
reverse = Reverse() reverse = Reverse()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论