2. Contents
1. Python 3
a. 3.6으로 시작
b. 적용 순서
c. 주요 문법 변화
d. 이슈들…
e. 얼마 남지 않았다
2. AsyncIO
a. 소개
b. 일반 예제
c. 적용 예제
d. 성능 차이
e. 업무 적용 사례
3. Summary
a. Python3
b. AsyncIO
4. 1. Python3 - a. 3.6으로 시작
● async def와 await는 파이썬 3.5에서 추가되었음
● 따라서 그 이하 버전에서는 사용할 수 없음
● 파이썬 3.4에서는 @asyncio.coroutine 데코레이터로 네이티브 코루틴을 생성
● 3.6(stable version)으로 시작하는것을 추천
5. 1. Python3 - b. 적용 순서
1. Python 3.6 Download(https://www.python.org/)
2. Read Readme
a. configure
b. make
c. make test
d. sudo make install
3. install python package
a. using pip3.6
11. 2. AsyncIO - b. 일반 예제
# Example 1: synchronous requests
import requests
num_requests = 20
responses = [
requests.get('http://example.org/')
for i in range(num_requests)
]
12. 2. AsyncIO - c. 적용 예제
# Example 2: asynchronous requests
import asyncio
import requests
async def main():
loop = asyncio.get_event_loop()
futures = [
loop.run_in_executor(
None,
requests.get,
'http://example.org/'
)
for i in range(20)
]
for response in await asyncio.gather(*futures):
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
17. 3. Summary - a. Python3
● Python은 v3를 써야만 한다.
● v2 -> v3 는 몇몇 경우를 제외하고는 그리 어렵지 않다.
● 지금 바로 넘어가세요~
18. 3. Summary - b. AsyncIO
● IO비중이 높다면 눈에 띄는 성능 개선!
● 그동안 무시해왔던 Python의 Multi Thread를 적극 활용.
● async, await, event loop, native coroutine 등의 개념은 study 필요.