#27870: Clean up autocomplete function
-------------------------------------+-------------------------------------
               Reporter:  Phil       |          Owner:  Phil
                   Type:             |         Status:  assigned
  Uncategorized                      |
              Component:  Core       |        Version:  master
  (Management commands)              |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

 2. 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)).

--
Ticket URL: <https://code.djangoproject.com/ticket/27870>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.876d9d6d7d1c07a096f2379c058dd507%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to