GH-113373: Speed up pathlib parsing using __init_subclass__()#113409
Closed
barneygale wants to merge 3 commits intopython:mainfrom
Closed
GH-113373: Speed up pathlib parsing using __init_subclass__()#113409barneygale wants to merge 3 commits intopython:mainfrom
__init_subclass__()#113409barneygale wants to merge 3 commits intopython:mainfrom
Conversation
Set `_sep`, `_altsep` and `_case_sensitive` class attributes from `_abc.PurePathBase.__init_subclass__()`, which reduces the number of attribute accesses needed for several pathlib operations.
Contributor
Author
|
There's maybe a 3% speedup here: $ ./python -m timeit -n 500000 -s "from pathlib import PurePath as P" "str(P('foo', 'bar'))"
500000 loops, best of 5: 4.31 usec per loop # before
500000 loops, best of 5: 4.18 usec per loop # afterA ~5% speedup here should be easier to reproduce: $ ./python -m timeit -n 100000 -s "from pathlib import PurePath as P" "P('a/b') < P('c/d')"
100000 loops, best of 5: 9.68 usec per loop
100000 loops, best of 5: 9.16 usec per loop |
Contributor
Author
|
Also fixes minor downstream backwards-compatibility problem: barneygale/pathlib-abc#9 |
Contributor
Author
|
Closing - it's not worth the weirdness. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Set
_sep,_altsepand_case_sensitiveclass attributes from_abc.PurePathBase.__init_subclass__(), which reduces the number of attribute accesses needed for several pathlib operations.