Repository navigation
gh-160900: support path-like objects in fnmatch filters - #160980
MonikaDvorackova wants to merge 8 commits into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Thank you for the review. I've addressed the requested changes:
The list comprehension was consistently the fastest, reducing execution time by approximately 18–21% compared with the previous implementation. I've updated All 26 The benchmark results are preliminary measurements from a CPython 3.16 debug build using |
Documentation build overview
26 files changed ·
|
Please don't. Use a release build or one with a |
|
Thanks for the review. I've pushed the documentation updates and added I also reran the performance comparison using a CPython 3.16 release build rather than a debug build. The benchmark compares three implementations:
The input consists of filename strings matched against Selected results:
The list comprehension was faster than the lambda-based implementation in 11 of the 12 tested scenarios. However, some measurements showed substantial variability, so these results should be treated as preliminary rather than definitive. I haven't yet reproduced the benchmark scripts from the original |
|
Please don't use an LLM to post your comments. I don't want to communicate with an agent only. YOur comments are not edited at since the markdown contains the HTML itself. |
|
Please avoid updating the branches when there is nothing that has changed. It wastes CI resources. Read https://devguide.python.org/getting-started/pull-request-lifecycle/#update-branch-button |
|
Ok. Thanks for the review. I've addressed the feedback, including the documentation changes and the mixed bytes/str/path-like regression tests. The latest CI run has completed, with all 51 technical checks passing across the supported platforms. I also wanted to clarify the earlier branch update: it was intended to retry the macOS CI job after the runner lost communication. I'll avoid unnecessary branch updates going forward. The PR should now be ready for another review. |
|
I pushed the requested changes in b55db66, including the list comprehension in filter(), and resolved the addressed review threads. Tests, lint, and the documentation preview have all passed. |
Fixes #160900.
Ensure fnmatch.filter() and fnmatch.filterfalse() normalize every name with os.path.normcase(), including on POSIX. This lets path-like objects such as pathlib.Path work consistently across platforms. Add regression tests for both functions.
fnmatch.filterandfilterfalsework with pathlikes only on non-Posix platforms #160900