Skip to content

Commit

Permalink
Compiling the regex outside the function
Browse files Browse the repository at this point in the history
  • Loading branch information
jpontoire committed Jan 10, 2025
1 parent c28763c commit 622fc24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions minet/reddit/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
)
from minet.web import request, create_pool_manager

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


def add_slash(url: str):
path = url.split("/")
Expand Down Expand Up @@ -86,8 +88,7 @@ def reddit_request(url, pool_manager):


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


def get_current_id(com):
Expand Down

0 comments on commit 622fc24

Please sign in to comment.