This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Optimize pathlib
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, FFY00, barneygale, christian.heimes, eric.araujo, josh.r, pitrou
Priority: normal Keywords: patch

Created on 2021-12-22 09:00 by kumaraditya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30226 closed kumaraditya, 2021-12-22 09:01
PR 27828 Dennis Sweeney, 2022-01-03 01:42
PR 30492 closed barneygale, 2022-01-09 02:21
Messages (10)
msg409015 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2021-12-22 09:00
Issue for tracking improving performance of pathlib module.
msg409023 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-12-22 10:46
Please provide benchmarks and reasons in the ticket. A BPO issue should contain all relevant information for a change.
msg409025 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2021-12-22 11:43
Optimizations include:

- Remove redundant check for functools lru_cache
- Replace attrgetter as it is slower than direct access
msg409026 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2021-12-22 11:44
Benchmarks for attrgetter is provided in the PR.
msg409048 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-12-22 18:43
I presume https://github.com/faster-cpython/ideas/discussions/194 is also relevant.
msg409059 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2021-12-23 01:41
Note: attrgetter could easily be made faster by migrating it to use vectorcall.
msg409060 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-12-23 01:48
> Note: attrgetter could easily be made faster by migrating it to use vectorcall.

Sure, though code that *doesn't* use attrgetter is usually easier to read -- attrgetter is rare enough in my experience that I usually have to look it up. So making attrgetter unnecessary in most cases would also be welcome.

(The exception is when you have many trivial pass-through properties, or when the attribute name is a variable to begin with.)
msg409064 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-12-23 05:11
I have https://github.com/python/cpython/pull/27828 open already to add vectorcall to itemgetter and attrgetter
msg409758 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2022-01-05 12:18
I am withdrawing this for now and since there is already a bpo for vectorcall I am closing this.
msg409773 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2022-01-05 15:27
A note about benchmarks: I think timeit is not the right tool for them, but https://github.com/python/pyperformance is
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90306
2022-01-09 09:41:34kumaradityasetnosy: - kumaraditya
2022-01-09 04:44:07gvanrossumsetnosy: - gvanrossum
2022-01-09 02:21:31barneygalesetnosy: + barneygale

pull_requests: + pull_request28697
2022-01-05 15:27:39eric.araujosetnosy: + eric.araujo
messages: + msg409773
2022-01-05 12:18:52kumaradityasetstatus: open -> closed
resolution: postponed
stage: patch review -> resolved
2022-01-05 12:18:33kumaradityasetmessages: + msg409758
2022-01-03 01:42:39Dennis Sweeneysetpull_requests: + pull_request28560
2021-12-23 05:16:40FFY00setnosy: + FFY00
2021-12-23 05:11:15Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg409064
2021-12-23 01:48:03gvanrossumsetmessages: + msg409060
2021-12-23 01:41:57josh.rsetnosy: + josh.r
messages: + msg409059
2021-12-22 22:08:50rhettingersetnosy: + pitrou
2021-12-22 18:43:48gvanrossumsetmessages: + msg409048
2021-12-22 11:44:25kumaradityasetmessages: + msg409026
2021-12-22 11:43:16kumaradityasetmessages: + msg409025
2021-12-22 10:46:17christian.heimessetnosy: + christian.heimes
messages: + msg409023
2021-12-22 09:01:22kumaradityasetkeywords: + patch
stage: patch review
pull_requests: + pull_request28449
2021-12-22 09:00:00kumaradityacreate