-
-
Notifications
You must be signed in to change notification settings - Fork 29.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-121445: C implementation for fnmatch
#121446
base: main
Are you sure you want to change the base?
Conversation
I forgot that MSVC didn't have an implementation of fnmatch... I'll add a guard for Windows so that it uses the pure Python implementation. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
So, everything should be ready. Documentation and NEWS entry need to be written and I also need to know how I can make it work on Windows. @zooba I know you are well-versed on Windows platforms so could you help me there please if you have time? How can I specify the files to be compiled correctly...? |
Easiest way is to look at any other similar module, find all the references to it, and set yours up the same way. Looks like you'll have a bit of rearranging to do here (e.g. header goes somewhere under Filename matching should also be a subset of regex, so it may be easier and more efficient to write our own comparison function. That would also then be fully portable, as well as being easier to handle compatibility. |
Thank you for that (actually, that's how I managed to do it for the linux build...). I actually never used MSVC so I don't know how to compile nor what I should actually specify but I'll do it the old way (trial and error).
For now, I've just replicated the Python implementation which translates UNIX shell patterns to RE patterns. Strictly speaking, I don't think the translation is needed when comparing filenames (since we would anyway use a subset of regex indeed), but I didn't want to introduce a new algorithm (which I more or less gave up to describe after 10 minutes...) |
- rename `regex.c` -> `matcher.c` - use interned strings - remove redundant macros - add comments to local macros - add some RFE notes
Mmmh... so the improvements are.... not improvements =/ Well I'll just forget about using interned strings actually. EDIT 2: mmh, actually it didn't change at all. So what happened between yesterday and today for 'fnmatch.translate' to be a bit slower... (maybe the merge?) |
fnmatch
[WIP]fnmatch
I think I'll leave the implementation like that for now and open it for review. At least, we have 1.7x performance gain for |
configure
script.lru_cache
os.path.normcase
fnmatch.fnmatch
fnmatch.fnmathcase
fnmatch.translate
fnmatch
#121445