Skip to content

Commit 622fc24

Browse files
committed
Compiling the regex outside the function
1 parent c28763c commit 622fc24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

minet/reddit/scraper.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
)
1313
from minet.web import request, create_pool_manager
1414

15+
ID_RE = re.compile(r"t1_(\w+)")
16+
1517

1618
def add_slash(url: str):
1719
path = url.split("/")
@@ -86,8 +88,7 @@ def reddit_request(url, pool_manager):
8688

8789

8890
def extract_t1_ids(text):
89-
pattern = r"t1_(\w+)"
90-
return [match.group(1) for match in re.finditer(pattern, text)]
91+
return [match.group(1) for match in re.finditer(ID_RE, text)]
9192

9293

9394
def get_current_id(com):

0 commit comments

Comments
 (0)