René's URL Explorer Experiment


Title: GH-101362: Optimise pathlib by deferring path normalisation by barneygale · Pull Request #101560 · python/cpython · GitHub

Open Graph Title: GH-101362: Optimise pathlib by deferring path normalisation by barneygale · Pull Request #101560 · python/cpython

X Title: GH-101362: Optimise pathlib by deferring path normalisation by barneygale · Pull Request #101560 · python/cpython

Description: PurePath now normalises and splits paths only when necessary, e.g. when .name or .parent is accessed. The result is cached. This speeds up path object construction by around 4x. PurePath.__fspath__() now returns an unnormalised path, which should be transparent to filesystem APIs (else pathlib's normalisation is broken!). This extends the earlier performance improvement to most impure Path methods, and also speeds up p.joinpath('bar') and p / 'bar'. edit: will fix separately. This also fixes GH-76846 and GH-85281 by unifying path constructors and adding an __init__() method. edit: will fix separately. Issue: gh-101362

Open Graph Description: PurePath now normalises and splits paths only when necessary, e.g. when .name or .parent is accessed. The result is cached. This speeds up path object construction by around 4x. PurePath.__fspath__...

X Description: PurePath now normalises and splits paths only when necessary, e.g. when .name or .parent is accessed. The result is cached. This speeds up path object construction by around 4x. PurePath.__fspath__...

Opengraph URL: https://github.com/python/cpython/pull/101560

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:89cc9a48-193c-f342-4715-d8b158d84bc7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDA38:31EA40:8C4598:BEF32B:6969E6E3
html-safe-nonce7193b614076c4e0ae0fc122ecba6b0456fbf46ce0a5dae377c6f5d602ef19d9a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTM4OjMxRUE0MDo4QzQ1OTg6QkVGMzJCOjY5NjlFNkUzIiwidmlzaXRvcl9pZCI6IjQwNTUyNTM2MDIzMzY4OTI2NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5d475eb361efc8f06b5f84c117105c886518c48e52e976e6efd01cd4e9aade9b
hovercard-subject-tagpull_request:1229157490
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/101560/files
twitter:imagehttps://avatars.githubusercontent.com/u/960340?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/960340?s=400&v=4
og:image:altPurePath now normalises and splits paths only when necessary, e.g. when .name or .parent is accessed. The result is cached. This speeds up path object construction by around 4x. PurePath.__fspath__...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/101560/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F101560%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F101560%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/101560/files
Reloadhttps://github.com/python/cpython/pull/101560/files
Reloadhttps://github.com/python/cpython/pull/101560/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/101560/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/101560/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
barneygalehttps://github.com/barneygale
python:mainhttps://github.com/python/cpython/tree/main
barneygale:optimize-pathlib-part-2bhttps://github.com/barneygale/cpython/tree/optimize-pathlib-part-2b
Conversation 5 https://github.com/python/cpython/pull/101560
Commits 16 https://github.com/python/cpython/pull/101560/commits
Checks 0 https://github.com/python/cpython/pull/101560/checks
Files changed https://github.com/python/cpython/pull/101560/files
Please reload this pagehttps://github.com/python/cpython/pull/101560/files
GH-101362: Optimise pathlib by deferring path normalisation https://github.com/python/cpython/pull/101560/files#top
Show all changes 16 commits https://github.com/python/cpython/pull/101560/files
b428069 GH-101362 - Optimise pathlib by deferring path normalisation barneygale Jan 27, 2023 https://github.com/python/cpython/pull/101560/commits/b428069b063d7641d721f1cf399c086f7e3c9729
e49e719 Restore str force-casting behaviour; reduce diff a little. barneygale Feb 4, 2023 https://github.com/python/cpython/pull/101560/commits/e49e7197c18543f8b71c197b20eda7c1858dd1c2
a931986 Fix pathlib usage error in importlib barneygale Feb 4, 2023 https://github.com/python/cpython/pull/101560/commits/a931986fa440c7d8f30fdd62135983bde2b8925a
38f70bf Improve initialiser performance. barneygale Feb 4, 2023 https://github.com/python/cpython/pull/101560/commits/38f70bf2f785ac37bc970b7789b0f29047144af5
10844a6 Add NEWS blurb barneygale Feb 4, 2023 https://github.com/python/cpython/pull/101560/commits/10844a64085292c249aad7dbc423de6bd35caa30
d5231b6 Store '_fspath' as non-empty string. barneygale Feb 4, 2023 https://github.com/python/cpython/pull/101560/commits/d5231b666939b3edbd97bd79759619462046fb21
76b2db7 Merge branch 'main' into optimize-pathlib-part-2b barneygale Mar 6, 2023 https://github.com/python/cpython/pull/101560/commits/76b2db76bbd17047d19f5e07b5b5639a4cae6a90
cc2c711 Undo addition of `__init__()` and change to `_from_parsed_parts()` barneygale Mar 6, 2023 https://github.com/python/cpython/pull/101560/commits/cc2c7111d73b3b33008fe3d848d99655a249bd76
cbf0fcd Fix pickling of paths created via walking. barneygale Mar 6, 2023 https://github.com/python/cpython/pull/101560/commits/cbf0fcd2890f3a0ce66bca91b8027d3432212f03
eb7087f Simplify patch slightly barneygale Mar 6, 2023 https://github.com/python/cpython/pull/101560/commits/eb7087f7a9f44823071559ba363c8cd0579a1981
3b53e27 Remove unused import barneygale Mar 11, 2023 https://github.com/python/cpython/pull/101560/commits/3b53e277b7d4eda2e87f6c51951dd0e6eebd3483
dec98f2 Merge branch 'main' into optimize-pathlib-part-2b barneygale Mar 11, 2023 https://github.com/python/cpython/pull/101560/commits/dec98f2212f9f179d43638f2de2c44b7e644a3c8
d9a6080 Fix dodgy merge, add comment about _from_parsed_parts() barneygale Mar 11, 2023 https://github.com/python/cpython/pull/101560/commits/d9a6080f78c2ffa1e4bc0f6c2d3171c36719c94e
9650dca Stop returning unnormalised path from `__fspath__()` barneygale Mar 17, 2023 https://github.com/python/cpython/pull/101560/commits/9650dca6ee972f8bb53198bfc7860a1e6dc510b0
af27476 Merge branch 'main' into optimize-pathlib-part-2b barneygale Mar 17, 2023 https://github.com/python/cpython/pull/101560/commits/af27476ddfb77d5e62daa0f19dd6e7d5e2c325a6
97995bd Undo change to `joinpath()`, fix news blurb. barneygale Mar 17, 2023 https://github.com/python/cpython/pull/101560/commits/97995bd2c3ea3c31bb420fab61d55b4ff0332bd0
Clear filters https://github.com/python/cpython/pull/101560/files
Please reload this pagehttps://github.com/python/cpython/pull/101560/files
Please reload this pagehttps://github.com/python/cpython/pull/101560/files
pathlib.py https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
test_pathlib.py https://github.com/python/cpython/pull/101560/files#diff-3dd97d2dc8816848d0b0c442e8fdeec9650b3de77935289a93f37ac6396ee17f
2023-02-04-17-47-08.gh-issue-101362.uZjk9-.rst https://github.com/python/cpython/pull/101560/files#diff-a346e663030bdcdd209f8c61bfd5720cca64da47b48e814f0127cf14fb5cff30
Lib/pathlib.pyhttps://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
View file https://github.com/barneygale/cpython/blob/97995bd2c3ea3c31bb420fab61d55b4ff0332bd0/Lib/pathlib.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/101560/{{ revealButtonHref }}
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
https://github.com/python/cpython/pull/101560/files#diff-fa525485738fc33d05b06c159172ff1f319c26e88d8c6bb39f7dbaae4dc4105c
Lib/test/test_pathlib.pyhttps://github.com/python/cpython/pull/101560/files#diff-3dd97d2dc8816848d0b0c442e8fdeec9650b3de77935289a93f37ac6396ee17f
View file https://github.com/barneygale/cpython/blob/97995bd2c3ea3c31bb420fab61d55b4ff0332bd0/Lib/test/test_pathlib.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/101560/{{ revealButtonHref }}
https://github.com/python/cpython/pull/101560/files#diff-3dd97d2dc8816848d0b0c442e8fdeec9650b3de77935289a93f37ac6396ee17f
https://github.com/python/cpython/pull/101560/files#diff-3dd97d2dc8816848d0b0c442e8fdeec9650b3de77935289a93f37ac6396ee17f
Misc/NEWS.d/next/Library/2023-02-04-17-47-08.gh-issue-101362.uZjk9-.rsthttps://github.com/python/cpython/pull/101560/files#diff-a346e663030bdcdd209f8c61bfd5720cca64da47b48e814f0127cf14fb5cff30
View file https://github.com/barneygale/cpython/blob/97995bd2c3ea3c31bb420fab61d55b4ff0332bd0/Misc/NEWS.d/next/Library/2023-02-04-17-47-08.gh-issue-101362.uZjk9-.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/101560/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.