News for hackers. Stuff that matters.
Re:Python, Catastrophic Regular Expressions and the GIL (2013) by cmacleod4 on Monday November 14, 2022 @10:21AM (#33595257)
Need I point out that one can avoid both the issues highlighted here by just using Tcl?

Regexps in Tcl use a non-backtracking implementation which handles such cases with minimal slowdown, e.g. the example shown with 16 and 32-character inputs:

    (dep) 7 % timerate {regexp (a+)+b aaaaaaaaaaaaaaaa}
    0.353737 µs/# 2826961 # 2826961 #/sec 1000.000 net-ms
    (dep) 8 % timerate {regexp (a+)+b aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
    0.412612 µs/# 2423587 # 2423587 #/sec 1000.000 net-ms
One discussion of this can be found at https://comp.lang.tcl.narkive.com/XPVME8zS/tcl-regexp-perfor... .

Tcl's threading implementation has no GIL, which not only avoids the type of lock-up described here, but also allows performance to scale to use all cores of your machine, see: https://www.hammerdb.com/blog/uncategorized/why-tcl-is-700-f... .

There are no comments on this comment yet.