CPython vs PyPy3

반디·2023년 1월 10일
0

Python

목록 보기
1/11

python code를 implement 하는 방법은 다양하고 Cpython과 PyPy는 python code를 implement하는 방법들 중 하나임

CPython

original & most-maintained implementation
보통 제일 빨리 업데이트 됨

CPython 작동방식
1. interpreter가 logic과 syntax error를 체크
2. error가 없다면, code를 byte code로 변환
3. byte code를 PVM(Python Virtual Machine)으로 전송하여 machine-readable language로 변환

byte code: machine code와 source code의 중간단계

PyPy3

JIT 컴파일러를 지원하는 implementation 방법
보통 CPython 보다 빠르지만 다음 두 경우에는 JIT 컴파일러가 사용되지 않으므로 속도 향상이 없을 수 있음

  • short-runnng processes: process 수행 시간 자체가 너무 짧은 경우
  • 작업이 run-time library에서 모두 수행되는 경우

run-time library: 프로그램 실행을 위해 컴파일러에 의해 수행되는 low-level routine
JIT 컴파일: 프로그램을 실행하기 전에 컴파일 하는 대신, 프로그램을 실행하는 시점에서 필요한 부분들을 즉석으로 컴파일하는 것,interpret 과정에서 자주 쓰이는 코드를 캐싱하여 interpreter의 느린 실행 속도를 개선

참고문헌
https://docs.python.org/3/reference/introduction.html
https://www.pypy.org/
https://www.geeksforgeeks.org/why-pypy3-is-preferred-over-python3/

profile
꾸준히!

0개의 댓글