Changes between Initial Version and Version 1 of Ticket #27870
- Timestamp:
- Feb 22, 2017, 7:28:24 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #27870
- Property Type Uncategorized → Cleanup/optimization
-
Ticket #27870 – Description
initial v1 1 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 There are few thing in {{{core/management/__init__.py}}}(https://github.com/django/django/blob/master/django/core/management/__init__.py) those look strange. 2 2 3 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.3 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. 4 4 Sure, time and memory optimizations are negligible in this case, but readability is more important. 5 5 6 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)).6 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)).