comprehension1 list method 성능 측정 list 를 만들 때, +, append, comprehension 등을 사용한다 각각의 성능측정 결과, 상황에 맞게 잘 사용하면 좋을 것 같다 le = 1000000 @print_method def test_concat(): # O(k) l=[] for i in range(le): l+=[i] @print_method def test_append(): # O(1) l=[] for i in range(le): l.append(i) @print_method def test_comprehension(): l=[i for i in range(le)] @print_method def test_range(): l=list(range(le)) test_concat() test_append() test_compreh.. 2020. 9. 15. 이전 1 다음