-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Rest Framework Settings file Performs an O(n) operation on settings access that could be O(1) #3786
Comments
@CuriousG102 mind submitting a PR to discuss further? |
Sounds like a smal improvement since values are cached after that but still possible |
Ah. I didn't notice the caching going on on line 214. That does indeed make this a small improvement. Otherwise it might have been a bit bigger depending on how often settings are accessed. In any case I'll make a PR after New Years celebrations. |
Thanks and enjoy the celebrations ! |
Calling .keys() on a dictionary returns an iterable, so doing a membership test against that iterable is an O(n) operation. By not including a call to .keys(), the same effect will be attained in O(1) time.
https://github.com/tomchristie/django-rest-framework/blob/af0ea8ef5136da30cb058b10a493d36619d24add/rest_framework/settings.py#L199
The text was updated successfully, but these errors were encountered: