FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-117686: Improve the performance of ntpath.expanduser() by nineteendo · Pull Request #117690 · python/cpython · GitHub

Repository navigation

gh-117686: Improve the performance of ntpath.expanduser() - #117690

Merged
erlend-aasland merged 6 commits into
python:mainfrom
nineteendo:speedup-ntpath.expanduser
Apr 10, 2024
Merged

erlend-aasland merged 6 commits into
python:mainfrom
nineteendo:speedup-ntpath.expanduser

Conversation

nineteendo commented Apr 9, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor

Benchmark

script
::test.bat
@echo off
echo 1 character && python -m timeit -s "import before.ntpath" "before.ntpath.expanduser('~a')" && python -m timeit -s "import after.ntpath" "after.ntpath.expanduser('~a')"
echo 10 characters && python -m timeit -s "import before.ntpath" "before.ntpath.expanduser('~' + 'a' * 10)" && python -m timeit -s "import after.ntpath" "after.ntpath.expanduser('~' + 'a' * 10)"
echo 100 characters && python -m timeit -s "import before.ntpath" "before.ntpath.expanduser('~' + 'a' * 100)" && python -m timeit -s "import after.ntpath" "after.ntpath.expanduser('~' + 'a' * 100)"
1 character
50000 loops, best of 5: 5.93 usec per loop # before
50000 loops, best of 5: 5.77 usec per loop # after
# -> 1.03x faster
10 characters
50000 loops, best of 5: 7.49 usec per loop # before
50000 loops, best of 5: 6.43 usec per loop # after
# -> 1.16x faster
100 characters
20000 loops, best of 5: 19.5 usec per loop # before
20000 loops, best of 5: 12.2 usec per loop # after
# -> 1.60x faster

nineteendo marked this pull request as ready for review April 9, 2024 18:22
Comment thread Lib/ntpath.py
erlend-aasland changed the title gh-117686: Move _get_bothseps() outside loop condition gh-117686: Improve the performance of ntpath.expanduser() Apr 9, 2024
Comment thread Lib/ntpath.py Outdated

erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this change is fine; it is small and non-intrusive, and readability is not impacted. Still, let's wait a day or two before merging in case anyone disagrees.

erlend-aasland commented Apr 10, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor

Thumbs up from Terry in #117686 (comment).

With two core devs being in favour, I'll go ahead and merge.

erlend-aasland merged commit f90ff03 into python:main Apr 10, 2024
nineteendo deleted the speedup-ntpath.expanduser branch April 10, 2024 08:42
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL