Commit 14e33770 authored by Stefan Behnel's avatar Stefan Behnel

optimise unicode.join()

parent 3b98c83a
...@@ -1444,6 +1444,24 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1444,6 +1444,24 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
node, "PyUnicode_Splitlines", self.PyUnicode_Splitlines_func_type, node, "PyUnicode_Splitlines", self.PyUnicode_Splitlines_func_type,
'splitlines', is_unbound_method, args) 'splitlines', is_unbound_method, args)
PyUnicode_Join_func_type = PyrexTypes.CFuncType(
Builtin.unicode_type, [
PyrexTypes.CFuncTypeArg("sep", Builtin.unicode_type, None),
PyrexTypes.CFuncTypeArg("iterable", PyrexTypes.py_object_type, None),
])
def _handle_simple_method_unicode_join(self, node, args, is_unbound_method):
"""Replace unicode.join(...) by a direct call to the
corresponding C-API function.
"""
if len(args) != 2:
self._error_wrong_arg_count('unicode.join', node, args, 2)
return node
return self._substitute_method_call(
node, "PyUnicode_Join", self.PyUnicode_Join_func_type,
'join', is_unbound_method, args)
PyUnicode_Split_func_type = PyrexTypes.CFuncType( PyUnicode_Split_func_type = PyrexTypes.CFuncType(
Builtin.list_type, [ Builtin.list_type, [
PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None), PyrexTypes.CFuncTypeArg("str", Builtin.unicode_type, None),
......
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