Share
Embed
Pragmatic Python
2018 Django Girls Seoul 4월 세미나에서 발표한 [Pragmatic Python] 발표 자료입니다.
Sunghyun Hwang
April 30, 2018
Transcript
58 slides
-
2 ടࢿഅ Sunghyun Hwang • Software Engineer at Rainist Co.,
Ltd. • Python 2014 ~ • Scala 2017 ~ • Microservice Architecture 2017 ~ • Email: [email protected] • Twitter: @_sunghyunzz • Github: @sunghyunzz -
import unittest class PragmaticPythonTest(unittest.TestCase): def test_is_python_pragmatic(self): self.assertTrue( are_many_companies_using_python('KR') ) import
unittest class PragmaticPythonTest(unittest.TestCase): def test_is_python_pragmatic(self): self.assertTrue( are_many_companies_using_python('KR') ) 4 -
import unittest class PragmaticPythonTest(unittest.TestCase): def test_is_python_pragmatic(self): self.assertTrue( are_many_companies_using_python('KR') ) import
unittest class PragmaticPythonTest(unittest.TestCase): def test_is_python_pragmatic(self): self.assertTrue( are_many_companies_using_python('KR') ) 5 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') fetch_nr_of_jobs('Server+Developer') 9 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') fetch_nr_of_jobs('Server+Developer') 10 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') fetch_nr_of_jobs('Server+Developer') 11 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') fetch_nr_of_jobs('Server+Developer') 12 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') 13 -
import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int:
r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 import requests URL = 'https://www.wanted.co.kr/api/v3/search?country=KR' def fetch_nr_of_jobs(q: str) -> int: r = requests.get(f'{URL}&query={q}') return r.json()['data']['jobs']['total'] fetch_nr_of_jobs('Python+Developer') # 115 fetch_nr_of_jobs('Server+Developer') # 269 14 -
(…) Simple is better than complex. (…) Readability counts. (…)
If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) (…) Simple is better than complex. (…) Readability counts. (…) If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) 17 PEP 20 — The Zen of Python https://www.python.org/dev/peps/pep-0020/ -
(…) Simple is better than complex. (…) Readability counts. (…)
If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) (…) Simple is better than complex. (…) Readability counts. (…) If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) 18 PEP 20 — The Zen of Python https://www.python.org/dev/peps/pep-0020/ -
(…) Simple is better than complex.. (…) Readability counts. (…)
If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) (…) Simple is better than complex. (…) Readability counts. (…) If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. (…) 19 PEP 20 — The Zen of Python https://www.python.org/dev/peps/pep-0020/ -
21 s = {1, 2, 3} print(4 in s) l
= [1, 2] * 5 print(l[:-1]) d = {1: 1, 2: 4, 3: 9} print(d[3]) -
22 data = [1, 2, 3] sum(d ** 2 for
d in data) -
23 l = [1, 2, 3, 4, 5] d =
{ i: i ** i for i in l if i % 2 == 1 } -
24 def fib(n): a, b = 0, 1 for i
in range(n): a, b = b, a + b return a -
25 from itertools import permutations data = [1, 2, 3]
for case in permutations(data): pass -
27 from flask import Flask app = Flask(__name__) @app.route("/") def
hello(): return "Hello World!" -
32 Card Recommendation O(NC * NG * NB * NS)
• NC = number of cards • NG = number of benefit groups per card • NB = number of benefits per benefit group • NS = number of user spendings -
33 import timeit def calc(): s = 0 for i
in range(10 ** 8): s += i return s print( timeit.timeit( "calc()", setup="from __main__ import calc", number=1 ) ) -
34 import timeit def calc(): s = 0 for i
in range(10 ** 8): s += i return s print( timeit.timeit( "calc()", setup="from __main__ import calc", number=1 ) ) 7.25s -
35 val t1 = System.nanoTime() var s: Long = 0
for (i ← 1 to 100000000) { s += i } val t2 = System.nanoTime() println((t2 - t1) / 1000000000.0) -
36 val t1 = System.nanoTime() var s: Long = 0
for (i ← 1 to 100000000) { s += i } val t2 = System.nanoTime() println((t2 - t1) / 1000000000.0) 0.36s -
44 jg (user card) biryong (contents) alfred (card) poong (promotion)
dishwasher (FAQ) -
45 https://www.redhat.com/en/blog/state-microservices Respondents believe in “using the right tool for
the right task” According to 44% Middleware respondents & 50% OpenShift respondents -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 48 -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 49 -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 50 -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 51 -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 53 -
Prototyping I/O HTTP API Tasks (script) Data Science & Analysis
Small Functions in MSA Prototyping I/O HTTP API Tasks (script) Data Science & Analysis Small Functions in MSA 54 -
58 Join Us! https://rainist.com/recruit/engineer • Back-end Engineer (Python/Scala) • Devops
Engineer • Data Engineer • Data Scientist • Growth Hacker • Web Front-end Engineer • Android Engineer • iOS Engineer • QA Engineer • Security Engineer