Skip to content

Commit 6dbd6bb

Browse files
Update str_ops.py
1 parent 4a9f006 commit 6dbd6bb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mypyc/primitives/str_ops.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,26 @@
277277
error_kind=ERR_MAGIC,
278278
)
279279

280+
# str.count(substring)
281+
method_op(
282+
name="count",
283+
arg_types=[str_rprimitive, str_rprimitive],
284+
return_type=c_pyssize_t_rprimitive,
285+
c_function_name="CPyStr_CountAll",
286+
error_kind=ERR_MAGIC,
287+
)
288+
289+
# TODO str.count(unicode, substring, start)
290+
291+
# str.count(substring, start, end)
292+
method_op(
293+
name="count",
294+
arg_types=[str_rprimitive, str_rprimitive, c_pyssize_t_rprimitive, c_pyssize_t_rprimitive],
295+
return_type=c_pyssize_t_rprimitive,
296+
c_function_name="PyUnicode_Count",
297+
error_kind=ERR_MAGIC,
298+
)
299+
280300
# str.replace(old, new)
281301
method_op(
282302
name="replace",

0 commit comments

Comments
 (0)