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.
* 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>
* has_patch: 0 => 1
* stage: Unreviewed => Ready for checkin
Comment:
The [https://github.com/django/django/pull/8096 PR] looks good.
--
Ticket URL: <https://code.djangoproject.com/ticket/27870#comment:2>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"cc5c1b7568ca77d32c8ecdb235f893aef0072f71" cc5c1b75]:
{{{
#!CommitTicketReference repository=""
revision="cc5c1b7568ca77d32c8ecdb235f893aef0072f71"
Fixed #27870 -- Cleaned up ManagementUtility.autocomplete().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27870#comment:3>