본문 바로가기

부스트캠프 AI Tech/Python

Data Structure

Stack

  • Last In First Out

Queue

  • First In First Out

Tuple

  • immutable한 list 

Set

  • 중복 x, non-sequential
  • union, intersection, difference

Dict

  • tuple(Key, Value)

Collections

  • built-in 구조
  • deque, Counter, OrderedDict, defaultdict, namedtuple

Deque

  • Linked list 지원
  • rotate, reverse, appendleft 등 가능
  • list보다 빠름

Ordered Dict

  • 입력 순서를 보장하는 dict
  • python 3.6이상부터는 기본 dict도 보장

default Dict

  • default value를 지정가능한 dict
  • key가 존재하지 않으면 default value를 뱉어냄

Counter

  • sequential type의 data 개수를 dict로 반환.
  • set의 연산들을 지원(union, intersection, difference)

Named Tuple

  • tuple 형태로 구조체 저장
  • like class
  • Point = namedtuple('Point',['x','y'])
    p = Point(11, 22)

 

%timeit function() # 소요 시간 측정

 

'부스트캠프 AI Tech > Python' 카테고리의 다른 글

Object Oriented Programming  (0) 2022.01.21
Pythonic code  (0) 2022.01.19
String  (0) 2022.01.19
Conditionals and loops  (0) 2022.01.18
Function and Formatting  (0) 2022.01.18