-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve glob_to_regex
performance and add case sensitivity flag
#268
Conversation
Is this something we can also do to the Synapse implementation? |
ARGH. Please can we draw a line in the sand and resurrect syutil, rather than having two or three copies of everything? |
I didn't know Synapse had an equivalent. Synapse's one seems far more clever and collapses runs of wildcards, which the technique here can't do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing #255 will involve more frequent usage of glob_to_regex, so it'd be nice if it didn't do so many string concatenations.
I'm not quite sure how — hopefully we're only running a few on startup anyway (since re.compile is expensive), but I can't argue that this is probably a better way of doing it.
Though it is probably about time to have syutil
; we do wind up with quite a bit of duplication :/.
sygnal/utils.py
Outdated
|
||
Args: | ||
glob (str) | ||
glob | ||
|
||
Returns: | ||
re.RegexObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just knock these lines out, they're noise at this point
Turns out that if someone sends you a glob with three That sort of lesson is one of the reasons I'm really keen we pull it out to a shared library, so we don't have to keep learning the same lesson. |
I did a direct translation of |
All the globs that Sygnal has to deal with come from the config thankfully. I do agree that we should move glob handling into syutil at some point and ditch this implementation. |
I wonder if @richvdh feels strongly enough about making reviving syutil a blocker for this or not? There's the usual story of there being nothing more permanent than a temporary solution :P. Otherwise, I'm happy to accept this now |
I guess not, but honestly I feel like we have this discussion every time someone touches some code that ought to be in syutil - "it's done now, let's leave it until next time". At some point we really have to just draw a line. IOW: I'd be much happier to see this fixed with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not, but honestly I feel like we have this discussion every time someone touches some code that ought to be in syutil - "it's done now, let's leave it until next time". At some point we really have to just draw a line.
I'd have to agree with this (without wanting to pick on you!); I've opened matrix-org/matrix-python-common#1, it's up to you if you want to take it on or not right now (though I think I'll raise it at the next triage meeting :)).
Let's land it right now with the copy+pasted code and commit to extracting it out before the end of the month. @richvdh If we don't extract it in time, I'll owe you a tipple of your choice. |
Replaced by #281 |
Fixing #255 will involve more frequent usage of
glob_to_regex
, so it'd be nice if it didn't do so many string concatenations.