문서의 임의 삭제는 제재 대상으로, 문서를 삭제하려면 삭제 토론을 진행해야 합니다. 문서 보기문서 삭제토론 PyPy (문단 편집) == 예제 == [[몬티 홀 문제]]로 테스트 해 보자. {{{#!syntax python import time import random def populate_doors(): # put a car behind one door door=['goat', 'goat', 'goat'] door[random.randint(0,2)]='car' return door wins = 0 losses = 0 time_start = time.time() # playing the game 100,000 times: for x in range(100000): doors=populate_doors() first_choice=random.randint(0,2) # choose a random door for y in range(3): # reveal first losing, unchosen door if doors[y] != 'car' and y != first_choice: doors[y] = 'out' break if doors[first_choice] == 'car': losses = losses + 1 # contestant switched to losing door else: wins = wins + 1 # contestant switched to winning door time_finish = time.time() print("All choices were switched.") print("Wins: ", wins) print("Losses: ", losses) print("Elapsed time: ", time_finish-time_start) }}} 코드 출처[* 현재 불능 [[http://www.danielveazey.com/tag/monty-hall-problem/]], 가장 유사한 곳 [[https://matthew-brett.github.io/dsfe/chapters/extra/monty_hall_lists]]] PyPy가 약 '''25'''배[* Python 2.7.11 x86_64, PyPy 5.1.0 x86_64 기준.] 빠르다. 물론 코드에 따라 배율에 차이가 있고 가끔씩 더 느린 코드도 있지만 어지간한 경우엔 PyPy쪽이 빠르다.[* 2021년 시스템 64비트, pypy 3.7.9와 python 3.9.2로 측정결과, pypy가 거의 2배 정도 빠름] [[분류:시스템 소프트웨어]][[분류:Python]]저장 버튼을 클릭하면 당신이 기여한 내용을 CC-BY-NC-SA 2.0 KR으로 배포하고,기여한 문서에 대한 하이퍼링크나 URL을 이용하여 저작자 표시를 하는 것으로 충분하다는 데 동의하는 것입니다.이 동의는 철회할 수 없습니다.캡챠저장미리보기