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

고성능 파이썬(2판)

by 오현석, 미샤 고렐릭, 이안 오스발트
May 2021
Beginner to intermediate
528 pages
11h 27m
Korean
Hanbit Media, Inc.
Content preview from 고성능 파이썬(2판)
286
고성능 파이썬(2판)
8.3.1
순차 처리
먼저 문자열의
bcrypt
해시를 계산하고 계산이 끝나면 데이터베이스에
HTTP
API
요청으로
결과를 전송하는 간단한 코드부터 시작해보자.
import
random
import
string
import
bcrypt
import
requests
def
do_task(difficulty):
"
""
지정한 difficulty(난이도) 정도에 따라 bcrypt로
10글자짜리 문자열에 대한 해시를 계산한다
"
""
passwd = ("
"
.join(random.sample(string.ascii_lowercase, 10)) 
.encode("utf8
"
))
salt = bcrypt.gensalt(difficulty) 
result = bcrypt.hashpw(passwd, salt)
return
result.decode("utf8
"
)
def
save_result_serial(result):
url = f
"
http://127.0.0.1:8080/add
"
response = requests.post(url, data=result)
return
response.json()
def
calculate_task_serial(num_iter, task_difficulty):
for
i
in
range(num_iter):
result ...
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