[issue46825] slow matching on regular expression

2022-02-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The re module does not support features corresponding to 
std::regex_constants::__polynomial in C++. Rewrite your regular expression or 
try to use alternative regex implementations (for example wrappers around the 
re2 library or C++ regex library).

--
nosy: +serhiy.storchaka
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46825] slow matching on regular expression

2022-02-22 Thread Matthew Barnett


Matthew Barnett  added the comment:

The expression is a repeated alternative where the first alternative is a 
repeat. Repeated repeats can result in a lot of attempts and backtracking and 
should be avoided.

Try this instead:

(0|1(01*0)*1)+

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46825] slow matching on regular expression

2022-02-22 Thread Heran Yang


New submission from Heran Yang :

I'm using `re.fullmatch` to match a string that only contains 0 and 1. The 
regular expression is: (0+|1(01*0)*1)+

It runs rather slow with Python 3.7, but when I try using regex in C++, with 
std::regex_constants::__polynomial, it works well.

Would someone take a look at it? Thx.

--
components: Regular Expressions
files: match.py
messages: 413700
nosy: HeRaNO, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: slow matching on regular expression
type: performance
versions: Python 3.7
Added file: https://bugs.python.org/file50636/match.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com