[issue42885] Regex performance problem with ^ aka AT_BEGINNING

2021-01-15 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42885] Regex performance problem with ^ aka AT_BEGINNING

2021-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm getting similar results in Python 3.9. [steve ~]$ python3.9 -m timeit -s "a = 'A'*1" -s "import re" "re.search('^x', a)" 5000 loops, best of 5: 67.3 usec per loop [steve ~]$ python3.9 -m timeit -s "a = 'A'*10" -s "import re" "re.search('^x',

[issue42885] Regex performance problem with ^ aka AT_BEGINNING

2021-01-10 Thread Arnim Rupp
New submission from Arnim Rupp : The re lib needs 7 seconds to check if a billion As start with an x. So e.g. this statement takes this long: re.search(r'^x', 'A' * 10) It takes longer, the longer the string is. The string handling is not the problem, checking if it starts which an