TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Compile Go regular expressions to Go code

31 pointsby cafxxalmost 4 years ago

2 comments

traceroute66almost 4 years ago
This comment[1] from ianlancetaylor on Github appears to provide reasons as to why the standard Go implementation of regex is less than optimal.<p><i>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.</i><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;19629#issuecomment-288152974" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;19629#issuecomment-28815...</a>
评论 #27585638 未加载
yakubinalmost 4 years ago
This could be useful for writing lexers. Although I typically need to interleave some &quot;decoding&quot; with proper lexing (like decoding escape sequences in strings, universal character names in identifiers etc.), which would make it harder, when you want to do it in a single pass.