gh-91524: Speed up the regular expression substitution#91525
Conversation
Functions re.sub() and re.subn() and corresponding re.Pattern methods are now 2-3 times faster for replacement strings containing group references.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
|
If use There are two data contracts that crossing functions:
Such data contracts increase the difficulty of code maintenance. If use typedef struct {
PyObject_VAR_HEAD
struct {
int type; // literal or group
PyObject *item;
} items[0];
} TemplateObject;In the current PR, adjacent groups also waste space. |
Sorry, something went wrong.
…thon into re-compile-template
I do not think so. The benefit of I may try to experiment with |
Sorry, something went wrong.
|
Thank you for review. The conditions of my sight make my to easily miss some details. I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @gpshead: please review the changes made to this pull request. |
Sorry, something went wrong.
Please do not do this. Your help compensates my disadvantage. |
Sorry, something went wrong.
|
It doesn't matter, the worst result is to postpone it to a later version. There are a few possible changes about re module before 3.11 Beta1, #91495, #32411, #91477. Maybe you have other issues to deal with. |
Sorry, something went wrong.
|
@animalize - While it is great you are concerned for others health, it comes across poorly to say things in an "ultimatum" style such as a "threat" to stop working with someone because they've implied they may have a health concern. This is not kind. In many cultures (including Python's) that conduct is seen as discrimination. It limits others opportunities based on your own presumption of their abilities. Among committers (which @serhiy-storchaka is a long time member of) none of us expect the steering council to micromanage our lives and most of us would rightfully reject that concept if we were to try. That isn't our purpose. While asking me or the SC to treat another committer specially was presumably voiced out of genuine concern here, it can come across as a put down that belittles their work even if this is not what you intended. We trust everyone to understand their own contribution abilities and act accordingly as they see fit. Code review collaboration is a way for all of us to fill in gaps in that we all have in our work. Nobody is perfect. (I'm replying with the above in this forum so that this response is visible to the same audience as the earlier messages that led to it.) Lets ultimately stay focused on the PR here. Thanks for your reviews! |
Sorry, something went wrong.
|
Sorry. I don't know what to say. I tried to improve this PR locally, IMHO the data contracts and the |
Sorry, something went wrong.
|
@serhiy-storchaka This PR has been approved by one other core dev, but not merged for some reason. The performance improvement seems worthwhile. Is there a reason why the branch has not been updated? If needed I can help to update the branch to current main |
Sorry, something went wrong.
|
Thanks Serhiy & reviewers! |
Sorry, something went wrong.
|
Thank you Gregory for the final polishing. |
Sorry, something went wrong.
Functions re.sub() and re.subn() and corresponding re.Pattern methods
are now 2-3 times faster for replacement strings containing group references.
Closes #91524