Opened 7 years ago

Last modified 7 years ago

#27870 closed Cleanup/optimization

Clean up autocomplete function — at Initial Version

Reported by: Phil Owned by: Phil
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

There are few thing in [core/management/init.py](https://github.com/django/django/blob/master/django/core/management/__init__.py) those look strange.

  1. In [line 257](https://github.com/django/django/blob/master/django/core/management/__init__.py#L257) there is the code like sorted(x)[0] which is similar to min(x). But the second one looks better, works for O(N) but not O(N log N) and doesn't spend memory for the new object.

Sure, time and memory optimizations are negligible in this case, but readability is more important.

  1. In [line 261](https://github.com/django/django/blob/master/django/core/management/__init__.py#L261) we declare list of used options but use only to understand if option was already used. So while we don't need order, but only want to check, if option is already used. So set is better than list both semantically and complexity (~ O(1) instead of O(N)).

Change History (0)

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