Description
You might be interested to know that the Go regexp library uses finite automata already to implement the regexp
package. From that package:
The regexp implementation provided by this package is guaranteed to run in time linear in the size of the input. ... For more information about this property, see
It should be trivial(1) to replace the current shellstyle
matcher with a translation to the regexp
module, and to check for performance differences.
(1) exercise left to the reader
The one place where shellstyle
might be faster than regexp
is if you require start and end matching and allow only one glob in the middle. At that point, shellstyle
becomes a shortcut for startswith("stuff before *") AND endswith("stuff after *") AND len(string) > len(expression)
.