Show HN: Compile Go regular expressions to Go code
regexp2go-demo.herokuapp.com
regexp2go-demo.herokuapp.com
As you say, in a language like Python, the regexp engine is implemented in C. So you are comparing a somewhat tuned Go implementation with a highly tuned C implementation. You also need to consider the characteristics of the engine. Go has chosen to follow the re2 path (not surprising, since Russ Cox is a major author of both Go and re2). re2 has much better performance characteristics than some other regexp engines, in that it never has an exponential slowdown, but that comes at a cost for other regexps. Even then, the C++ re2 implementation has many optimizations that are not in the Go implementation.
[1] https://github.com/golang/go/issues/19629#issuecomment-28815...
On the avoiding exponential slowdown front, regexp2go and other re2-inspired implementations (including e.g. rust's) all have that as a goal.