Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
85bd018c69da
Commit
55e8a7f3
authored
Mar 03, 2021
by
Carl Friedrich Bolz-Tereick
Browse files
add a jit driver for re.split
parent
3d4b01405e77
Pipeline
#18754
passed with stage
in 7 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pypy/module/_sre/interp_sre.py
View file @
85bd018c
...
...
@@ -248,7 +248,11 @@ class W_SRE_Pattern(W_Root):
ctx
=
self
.
make_ctx
(
w_string
)
last
=
ctx
.
ZERO
while
not
maxsplit
or
n
<
maxsplit
:
if
not
searchcontext
(
space
,
ctx
,
self
.
code
):
pattern
=
self
.
code
num_groups
=
self
.
num_groups
split_jitdriver
.
jit_merge_point
(
pattern
=
pattern
,
num_groups
=
num_groups
,
ctx_type
=
type
(
ctx
))
if
not
searchcontext
(
space
,
ctx
,
pattern
):
break
if
ctx
.
match_start
==
ctx
.
match_end
:
# zero-width match
if
ctx
.
match_start
==
ctx
.
end
:
# or end of string
...
...
@@ -258,8 +262,8 @@ class W_SRE_Pattern(W_Root):
splitlist
.
append
(
slice_w
(
space
,
ctx
,
last
,
ctx
.
match_start
,
space
.
w_None
))
# add groups (if any)
fmarks
=
do_flatten_marks
(
ctx
,
self
.
num_groups
)
for
groupnum
in
range
(
self
.
num_groups
):
fmarks
=
do_flatten_marks
(
ctx
,
num_groups
)
for
groupnum
in
range
(
num_groups
):
groupstart
,
groupend
=
fmarks
[
groupnum
*
2
],
fmarks
[
groupnum
*
2
+
1
]
splitlist
.
append
(
slice_w
(
space
,
ctx
,
groupstart
,
groupend
,
space
.
w_None
))
...
...
@@ -405,6 +409,17 @@ class W_SRE_Pattern(W_Root):
space
.
newlist
(
sublist_w
))
return
w_item
,
n
def
sub_get_printable_location
(
filter_is_callable
,
use_builder
,
filter_type
,
pattern
):
s
=
str
(
pattern
)
if
len
(
s
)
>
120
:
s
=
s
[:
110
]
+
'...'
if
use_builder
==
'
\x00
'
:
use_builder
=
'list'
else
:
use_builder
=
"%sBuilder"
%
use_builder
return
"re.sub %s %s %s %s"
%
(
s
,
filter_is_callable
,
use_builder
,
filter_type
)
sub_jitdriver
=
jit
.
JitDriver
(
reds
=
"""count n last_pos
ctx w_filter
...
...
@@ -412,8 +427,23 @@ sub_jitdriver = jit.JitDriver(
filter_as_string
w_string sublist_w
self"""
.
split
(),
greens
=
[
"filter_is_callable"
,
"use_builder"
,
"filter_type"
,
"pattern"
])
greens
=
[
"filter_is_callable"
,
"use_builder"
,
"filter_type"
,
"pattern"
],
get_printable_location
=
sub_get_printable_location
,
)
def
split_get_printable_location
(
num_groups
,
ctx_type
,
pattern
):
s
=
str
(
pattern
)
if
len
(
s
)
>
120
:
s
=
s
[:
110
]
+
'...'
return
"re.split %s %s %s"
%
(
s
,
num_groups
,
ctx_type
)
split_jitdriver
=
jit
.
JitDriver
(
reds
=
"auto"
,
greens
=
[
"num_groups"
,
"ctx_type"
,
"pattern"
],
get_printable_location
=
split_get_printable_location
,
)
def
_sub_append_slice
(
ctx
,
space
,
use_builder
,
sublist_w
,
strbuilder
,
start
,
end
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment