#27870: Clean up autocomplete function
-------------------------------------+-------------------------------------
Reporter: Phil | Owner: Phil
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Phil):
* type: Uncategorized => Cleanup/optimization
Old 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.
>
> 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)).
New 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.
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#comment:1>
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/064.bce03dc55ff642ec78118bfc7cce42ce%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.