Skip to Content
고성능 파이썬(2판)
book

고성능 파이썬(2판)

by 오현석, 미샤 고렐릭, 이안 오스발트
May 2021
Beginner to intermediate
528 pages
11h 27m
Korean
Hanbit Media, Inc.
Content preview from 고성능 파이썬(2판)
108
고성능 파이썬(2판)
예제
3-7
append
와 리스트 내포의 메모리 사용량과 실행 시간 차이 비교
>>> %memit [i*i
for
i
in
range(100_000)]
peak memory: 70.50 MiB, increment: 3.02 MiB
>>> %%memit l = []
...
for
i
in
range(100_000):
... l.append(i * 2)
...
peak memory: 67.47 MiB, increment: 8.17 MiB
>>> %timeit [i*i
for
i
in
range(100_000)]
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.
Start your free trial

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
엑셀이 편해지는 파이썬

엑셀이 편해지는 파이썬

펠릭스 춤슈타인
핸즈온 비지도 학습

핸즈온 비지도 학습

강재원, 권재철, 안쿠르 A. 파텔

Publisher Resources

ISBN: 9791162244210