27 comments

[ 3.2 ms ] story [ 65.3 ms ] thread
I guess you meant Python 3.4 because 3.5 has no limitation: https://github.com/python/cpython/blob/3.5/Lib/sre_compile.p...
yeah it took me a bit to figure it out but "lt" in the original post text is supposed to mean "less than" or "older than"..
I thought it said "Python it"
It thought it meant long-term.
I was betting on a python lite implementation for embedded boards.
Hacker News strips < and > from titles, which is probably why they used "lt" instead.
Yes you are right, sorry for the confusion
Some might say if you need 100+ regex groups you have other problems...
I've got 99 problems, but >100 regex tables isn't one.
(comment deleted)
If you're using regular expressions for lexing anything moderately complex, e.g a wiki markup, you could easily find yourself needing 100+ groups, especially if you're generating the expressions from some kind of input grammar
If you are lexing there is a much better way than trying to munge together a giant regex manually:

https://github.com/python/cpython/blob/3.4/Lib/re.py#L346

No, using a completely undocumented class that heavily relies on further undocumented parts of the standard library that might be implementation details of the regex implementation is much better.
It's been there for like 10 years, I think you'll be ok if you use it... If it goes away, you can just bring it back right?
It'll stay but it's still undocumented and the code heavily relies on things that are undocumented as well. This makes understanding it unnecessarily difficult and forces you to comment your own code quite extensively.

On the other hand you can easily generate a regular expression by doing a little bit of trivial string manipulation everyone is going to understand.

So take the 'undocumented' code, copy it, paste it into a file, put the license comment at the top, and move on with your life. String munging regexes together is going to be slower and error prone.
Or you are using regexes generated programmatically.
> raise error("groups number is too large")

Oh, I hate that kind of error message. Why couldn't it be something useful like

    raise error("groups number is too large "
                "(you have used %d out of an "
                "allowed %d)" % (self.groups, MAXGROUPS))
It has a todo. Possibly just s fast hack till you can come back and fix it... Then fast hack became release :)
(comment deleted)
I'd like to see someone type a regex with 100 capturing groups.
I'd like to see someone _debug_ a regex with 100 capturing groups.
Such expressions are likely to be generated. In fact, the Python issue refers to a lexer for javascript. Imagine your design is to have one capturing group for each different language keyword, and suddenly it doesn't seem so silly any longer. https://bugs.python.org/issue22437
Cpython, right? Not python the language,if I understand this correctly.
Yeah, like GHC supporting only up to 62-tuple. Very limiting.