Message367963
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:
(?s:.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*b)\\Z
It's equivalent to:
(?s:.*b)\\Z
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:07 | kleshni | set | recipients:
+ kleshni |
2020-05-03 09:37:07 | kleshni | set | messageid: <1588498627.36.0.0280402477391.issue40480@roundup.psfhosted.org> |
2020-05-03 09:37:07 | kleshni | link | issue40480 messages |
2020-05-03 09:37:07 | kleshni | create | |
|