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

고성능 파이썬(2판)

by 오현석, 미샤 고렐릭, 이안 오스발트
May 2021
Beginner to intermediate
528 pages
11h 27m
Korean
Hanbit Media, Inc.
Content preview from 고성능 파이썬(2판)
105
3
리스트와 튜플
3.2.1
리스트: 동적 배열
리스트는 생성한 후에도 언제든 내용을 변경할 수 있다.
>>> numbers = [5, 8, 1, 3, 2, 6]
>>> numbers[2] = 2 * numbers[0] 
>>> numbers
[5, 8, 10, 3, 2, 6]
앞서 설명했듯이,
0
번째 항목과 두 번째 항목을 바로 찾을 수 있으므로 이 연산의 시간복잡
도는
O
(
1
)
이다.
그리고 리스트에 새로운 데이터를 추가하면 크기가 커진다.
>>> len(numbers)
6
>>> numbers.append(42)
>>> numbers
[5, 8, 10, 3, 2, 6, 42]
>>> len(numbers)
7
이는 동적 배열이 배열의 크기를 변경하는
resize
연산을 지원하기에 가능하다. 크기가
N
꽉 찬 리스트에 새로운 항목을 추가하면 파이썬은 원래 항목
N
개와 새로 추가한 항목까지 모두
담을 만한 크기의 새로운 리스트를 생성한다. 하지만 크기를
N
+
1
할당하지 않고 나중을 위한
여유분으로
N
보다 큰
M
만큼 메모리를 할당한다(
M
>
N
). 그리고 이전 리스트의 데이터를 모두
새로운 리스트로 복사하고 이전 리스트는 삭제한다.
크기에 여유를 두는 이유는 리스트에 값을 한 번 추가하면 그 뒤로도 여러 번 더 추가할 확률이
높으니 메모리 할당과 복사 요청 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
핸즈온 비지도 학습

핸즈온 비지도 학습

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

Publisher Resources

ISBN: 9791162244210