Skip to content
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

Fixed #35252 -- Optimized _route_to_regex(). #17908

Merged
merged 1 commit into from Mar 5, 2024

Conversation

adamchainz
Copy link
Sponsor Member

django/urls/resolvers.py Outdated Show resolved Hide resolved
django/urls/resolvers.py Outdated Show resolved Hide resolved
django/urls/resolvers.py Outdated Show resolved Hide resolved
django/urls/resolvers.py Outdated Show resolved Hide resolved
django/urls/resolvers.py Outdated Show resolved Hide resolved
django/urls/resolvers.py Outdated Show resolved Hide resolved
@adamchainz
Copy link
Sponsor Member Author

Thanks for the review @ngnpope, I'll action it tonight.

@adamchainz
Copy link
Sponsor Member Author

Alright, done tonight. @ngnpope would you mind accepting the ticket, since it seems you think the optimization is worthwhile and safe?

co-authored-by: Nick Pope <nick@nickpope.me.uk>
Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamchainz Thanks 👍


@functools.cache
def get_converters():
return {**DEFAULT_CONVERTERS, **REGISTERED_CONVERTERS}


def get_converter(raw_converter):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a release note about removing this undocumented function.

break
elif not set(match.group()).isdisjoint(string.whitespace):
previous_end = 0
for match in _PATH_PARAMETER_COMPONENT_RE.finditer(route):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed match to match_ to avoid using a keyword.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. It's a soft keyword deliberately to not break use of regexes like this, as I heard recently on https://podcasts.apple.com/gb/podcast/core-py/id1712665877?i=1000647675451 😉

@felixxm felixxm merged commit eff21d8 into django:main Mar 5, 2024
35 checks passed
@adamchainz adamchainz deleted the ticket_35252 branch March 8, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants