Title: Optimize `pathlib.PurePath.__fspath__()` · Issue #102783 · python/cpython · GitHub
Open Graph Title: Optimize `pathlib.PurePath.__fspath__()` · Issue #102783 · python/cpython
X Title: Optimize `pathlib.PurePath.__fspath__()` · Issue #102783 · python/cpython
Description: Feature or enhancement Return an unnormalized path from pathlib.PurePath.__fspath__() Pitch Code like open(Path('./README.txt')) or Path('/home//barney').iterdir() shouldn't require us to normalize the path in pathlib (e.g. remove . segm...
Open Graph Description: Feature or enhancement Return an unnormalized path from pathlib.PurePath.__fspath__() Pitch Code like open(Path('./README.txt')) or Path('/home//barney').iterdir() shouldn't require us to normalize...
X Description: Feature or enhancement Return an unnormalized path from pathlib.PurePath.__fspath__() Pitch Code like open(Path('./README.txt')) or Path('/home//barney').iterdir() shouldn't req...
Opengraph URL: https://github.com/python/cpython/issues/102783
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Optimize `pathlib.PurePath.__fspath__()`","articleBody":"# Feature or enhancement\r\n\r\nReturn an *unnormalized* path from `pathlib.PurePath.__fspath__()`\r\n\r\n# Pitch\r\n\r\nCode like `open(Path('./README.txt'))` or `Path('/home//barney').iterdir()` shouldn't require us to normalize the path in pathlib (e.g. remove `.` segments, doubled slashes, etc), as OS APIs are perfectly happy with unnormalized paths.\r\n\r\nWe can improve the performance of most `Path` methods, and the effective performance of passing a `Path` object to any API that accepts `os.PathLike`, by skipping normalization in `__fspath__()`.\r\n\r\n# Prerequisites\r\n\r\nPathlib must not normalize paths on construction:\r\n\r\n- https://github.com/python/cpython/issues/101362\r\n\r\nPathlib's normalization must not change the meaning of paths:\r\n\r\n- https://github.com/python/cpython/issues/65238\r\n- https://github.com/python/cpython/issues/78079\r\n\r\n# Previous discussion\r\n\r\n- https://github.com/python/cpython/pull/101560\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-112397\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/barneygale","@type":"Person","name":"barneygale"},"datePublished":"2023-03-17T16:24:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/102783/cpython/issues/102783"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3e4a0c3b-43fe-ad7c-a05e-9a4bdc30e240 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB2A:C07BE:2088EC:2B55D9:6969BF30 |
| html-safe-nonce | 28f685104cf30479ffe64d9117effc3e1edf762ddb78d4a1ab6711e5b7c4360f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjJBOkMwN0JFOjIwODhFQzoyQjU1RDk6Njk2OUJGMzAiLCJ2aXNpdG9yX2lkIjoiNDM0MTI5MzI2MDQzNjc2NDY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 648b8c9e0c9a6390e0086dde24437eb4f63d50d7a0885d0b496e4fcda5be179a |
| hovercard-subject-tag | issue:1629593986 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/102783/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0927147d37118d7152dc236dc11ccb3741c8165acb45edc071fcca296951ad91/python/cpython/issues/102783 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0927147d37118d7152dc236dc11ccb3741c8165acb45edc071fcca296951ad91/python/cpython/issues/102783 |
| og:image:alt | Feature or enhancement Return an unnormalized path from pathlib.PurePath.__fspath__() Pitch Code like open(Path('./README.txt')) or Path('/home//barney').iterdir() shouldn't require us to normalize... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | barneygale |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width