This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年01月06日 21:43 by ericp, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg150770 - (view) | Author: Eric Promislow (ericp) | Date: 2012年01月06日 21:43 | |
This regular expression takes a few seconds to be evaluated against any text: (.*?)((?:X|\s+)*)$ This reg ex is much faster: (.*?)((?:X|\s)*)$ To be fair, Ruby's performance with the first regex is the same as Python's. PHP and JavaScript both fail to match the first regex at all. Only Perl evaluates both regexes nearly instantly. |
|||
| msg151221 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年01月14日 04:10 | |
I believe it is a known fact that repeated repeats, like (...+)*, make for slow matching (if they work at all) with the current re engine. [I would not be surprised if Perl does some special casing to (in effect at least) rewrite the re to your second version.] This is not going to be improved in 2.7, nor immediately in 3.x. You can try the regex module on pypi, but it may act the same. I suspect there are similar issues like this on the tracker. Best to write the re properly. [Antoine or Ezio: If you think I am mistaken in closing this, please reopen.] |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:25 | admin | set | github: 57932 |
| 2012年11月07日 17:43:13 | mark.dickinson | set | superseder: the re module can perform poorly: O(2**n) versus O(n**2) |
| 2012年01月14日 04:10:05 | terry.reedy | set | status: open -> closed nosy: + terry.reedy, ezio.melotti, pitrou messages: + msg151221 resolution: wont fix |
| 2012年01月06日 21:46:33 | alex | set | nosy:
+ alex |
| 2012年01月06日 21:43:55 | ericp | create | |