Skip to content

Commit 6f58395

Browse files
committed
speeeeeed
1 parent 558077b commit 6f58395

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

regex/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .regex import *

regex/regex.cp38-win_amd64.pyd

1.29 MB
Binary file not shown.

tests/timer.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import regex
2+
import re
3+
import time
4+
5+
body = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931). "
6+
7+
RUNS = 1000
8+
9+
10+
exp = regex.Regex(
11+
r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"
12+
)
13+
14+
start = time.perf_counter()
15+
for _ in range(RUNS):
16+
exp.is_match(body * 10_000)
17+
stop = time.perf_counter() - start
18+
print(f"Rust Regex took: {round((stop * 1000) / RUNS, 4)}ms")
19+
20+
exp = re.compile(
21+
r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
22+
23+
start = time.perf_counter()
24+
for _ in range(RUNS):
25+
exp.match(body * 10_000)
26+
stop = time.perf_counter() - start
27+
print(f"Python Regex took: {round((stop * 1000) / RUNS, 4)}ms")
28+

0 commit comments

Comments
 (0)