7.99 ms ± 219 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
>>> %%timeit l = []
...
for
i
in
range(100_000):
... l.append(i * 2)
...
12.2 ms ± 184 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
파이썬 문장을 추가로 실행해야 하고 메모리도 재할당해야 하므로 전체 실행 시간도 더 느리
다. 이 문제는 작은 리스트를 많이 사용하거나, 아주 큰 리스트를 사용할 때 특히 두드러진다.
항목이
10
개인 리스트를
1
백만 개 저장하면 항목
1
천만 개에 해당하는 메모리를 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.