GH-104104: Optimize `pathlib.Path.glob()` by avoiding repeated calls to `os.path.normcase()` by barneygale · Pull Request #104105 · python/cpython
Conversation
…calls to `os.path.normcase()` Use `re.IGNORECASE` to implement case-insensitive matching. This restores behaviour from before python#31691.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great speedup! LGTM.
What was the motivation for moving to the normcase-based implementation in #31691? Did it just feel simpler at the time?
What was the motivation for moving to the
normcase-based implementation in #31691? Did it just feel simpler at the time?
Mostly because os.path doesn't have an attribute indicating whether it's case sensitive or not, and it didn't occur to me at the time to use normcase('Aa') == 'Aa'.
I think you should add an entry to "What's new in 3.12" about all the great optimisation work you've been doing on pathlib. It's a really good improvement that's worth celebrating :)
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