[issue30413] Add fnmatch.filter_false function

Wolfgang Maier report at bugs.python.org
Sat May 20 13:08:40 EDT 2017


Wolfgang Maier added the comment:

Hi,
seems I had the same thoughts as you, Steven. I had started working on a patch independently yesterday, but after making my changes to fnmatch itself, I found I had too many other things to do to address unittests and doc changes to turn this into a real patch - so thank you for spending time on all of this.
I just downloaded your patch and merged it with mine because I think my version of fnmatch.py may be simpler and slightly faster (though like you I didn't run performance tests). Feel free to do whatever you like with this alternate version - it's not that there is much new in it to take credit for :)

Another thing I noted: fnmatch takes a rather unusual approach to determine whether normcase is NOP or not. It imports posixpath only to see if it is the same as os.path. That looks pretty weird and wasteful to me (especially if you are running this on Windows and are effectively importing posixpath just for fun then). I think it would be better to just check os.name instead (like pathlib does for example). I moved the corresponding check to the top of the module to make this easier to address, should that be of interest. I'm also using the result of the check in fnmatch.fnmatch because I don't see any reason why you wouldn't want to benefit from it there as well.

----------
nosy: +wolma
Added file: http://bugs.python.org/file46880/filterfalse.alternate_patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30413>
_______________________________________


More information about the Python-bugs-list mailing list