Skip to content

Conversation

jacobtylerwalls
Copy link
Contributor

@jacobtylerwalls jacobtylerwalls commented Jun 12, 2021

Noticed while working on #26687 that one of the tests in test_urlparse took ~7s. Here I've short-circuited the filtering of a massive list comprehension (sys.maxunicode for me is 1,114,111) by checking if not empty before running split(), set(), &, etc.

LMK if this needs a ticket.


$ ./python.exe -m unittest test.test_urlparse.UrlParseTestCase.test_urlsplit_normalization

Before
Ran 1 test in 6.981s

After
Ran 1 test in 2.459s

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

1108247 chars of 1113983 (99.4%) can use short-circuited pass on my local machine :)

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

@serhiy-storchaka
I think that this PR is worth to review :) Can you please take a look?

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jul 22, 2021
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM

@serhiy-storchaka serhiy-storchaka merged commit c0f2fcf into python:main Jul 22, 2021
sthagen added a commit to sthagen/python-cpython that referenced this pull request Jul 22, 2021
Speed up test_urlsplit_normalization (pythonGH-26688)
@serhiy-storchaka
Copy link
Member

Thank you for your contribution @jacobtylerwalls.

@jacobtylerwalls jacobtylerwalls deleted the urlsplit-test-speed branch October 2, 2021 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip issue skip news stale Stale PR or inactive for long period of time. tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants