Author kleshni
Recipients kleshni
Date 2020-05-03.09:37:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hello. The following code hangs:

import fnmatch
fnmatch.fnmatchcase("a" * 32, "*" * 16 + "b")

Measurements show that its execution time rises exponentially with the number of asterisks. Bash and SQLite 3 process this glob instantly.

This is because "fnmatchcase" generates a regular expression with repeated dots:


It's equivalent to:


But works in exponential time. So the solution is to replace multiple asterisks with a single one, so the latter regexp is generated instead.
Date User Action Args
2020-05-03 09:37:07kleshnisetrecipients: + kleshni
2020-05-03 09:37:07kleshnisetmessageid: <>
2020-05-03 09:37:07kleshnilinkissue40480 messages
2020-05-03 09:37:07kleshnicreate