Skip to content

Commit cd74d32

Browse files
authored
Implement a primitive op for str.join (mypyc/mypyc#689)
1 parent 416732e commit cd74d32

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mypyc/ops_str.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from mypyc.ops import (
44
object_rprimitive, str_rprimitive, bool_rprimitive, ERR_MAGIC, ERR_NEVER, EmitterInterface
55
)
6-
from mypyc.ops_primitive import func_op, binary_op, simple_emit, name_ref_op
6+
from mypyc.ops_primitive import func_op, binary_op, simple_emit, name_ref_op, method_op
77

88

99
name_ref_op('builtins.str',
@@ -24,6 +24,13 @@
2424
error_kind=ERR_MAGIC,
2525
emit=simple_emit('{dest} = PyUnicode_Concat({args[0]}, {args[1]});'))
2626

27+
method_op(
28+
name='join',
29+
arg_types=[str_rprimitive, object_rprimitive],
30+
result_type=str_rprimitive,
31+
error_kind=ERR_MAGIC,
32+
emit=simple_emit('{dest} = PyUnicode_Join({args[0]}, {args[1]});'))
33+
2734
# PyUnicodeAppend makes an effort to reuse the LHS when the refcount
2835
# is 1. This is super dodgy but oh well, the interpreter does it.
2936
binary_op(op='+=',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy