Opened 8 weeks ago

Closed 7 weeks ago

#28642 closed Cleanup/optimization (fixed)

Add LRU caching to parse_accept_lang_header

Reported by: Tom Forbes Owned by: nobody
Component: Internationalization Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Re: https://github.com/django/django/pull/9116#issuecomment-332368698

I think utils.translation.trans_real.parse_accept_lang_header would benefit from having a lru_cache added to it, because the single input is quite regular, and while the function isn't supremely complex it does do a few things (regex split, float casting, sorting based on key) for every request.

The function currently returns a list, this would need to be changed to a tuple.

Change History (2)

comment:1 Changed 8 weeks ago by Aymeric Augustin

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 weeks ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In f1c007bb:

Fixed #28642 -- Added caching to parse_accept_lang_header().

Note: See TracTickets for help on using tickets.
Back to Top