Skip to content

search_pypi_top: add --multiline option - #24

Merged
vstinner merged 1 commit into
vstinner:mainfrom
StanFromIreland:multiline
Nov 4, 2026
Merged

vstinner merged 1 commit into
vstinner:mainfrom
StanFromIreland:multiline

Conversation

@StanFromIreland

Copy link
Copy Markdown
Contributor

It searches the whole file at once so the regex can match across lines. The regex is also compiled with re.MULTILINE, and each line is reported at most once. This was helpful to me to gather data for a PEP I'm working on, as the idioms I was looking for spanned two or three lines.

CC @hugovk @vstinner

@StanFromIreland StanFromIreland mentioned this pull request Oct 27, 2026
25 of 29 tasks
yield from _grep_lines(archive_filename, filename, fp, regex)


def _grep_lines(archive_filename, filename, fp, regex):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I would prefer to not have to maintain two implementatons. Can't we just use _grep_multiline() in all cases (multiline or not)? Just inline _grep_multiline() again in grep().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would slow down (by a noticeable amount) searches that could be done on a line by line basis, as such I opted to make it optional.

if IGNORE_CYTHON and CYTHON_REGEX.match(data):
logger.info(f"ignore Cython file: {archive_filename}: {filename}")
return
last_start = -1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
last_start = -1
last_start = None

@vstinner
vstinner merged commit 907d84e into vstinner:main Nov 4, 2026
@vstinner

vstinner commented Nov 4, 2026

Copy link
Copy Markdown
Owner

I merged your change, thanks for your contribution. I didn't really have time to test this change myself, but I trust you for testing it :-)

@StanFromIreland
StanFromIreland deleted the multiline branch November 4, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants