Python/Python 뜯어보기

[Python 뜯어보기] 5. 파이썬 가상머신(PVM) 과 컴파일방식

동현 유 2022. 4. 13. 16:58

java bytecode 찾아보다가 파이썬도 바이트코드를 확인할 수 있다는 것을 우연히 발견하게 되었다. 

 

아니 그렇다는 것은,,

자바와 마찬가지로 파이썬도

컴파일 된 후에 인터프리터를 하는 하이브리드 방식이라는 얘기인가?!?!

하고 찾아봤다. 

 


python VM 이 코드를 interpret 하는 과정

https://caiocozza-art.medium.com/a-quick-overview-of-the-python-virtual-machine-pt-1-315e74c036f4

 

A quick overview of the Python Virtual Machine — Pt. 1

This is the part one of a series covering aspects of Virtual Machines and how an interpreted programming language performs it’s executions.

caiocozza-art.medium.com

 

 

파이썬 바이트코드 확인하는 모듈 

https://docs.python.org/ko/dev/library/dis.html

 

dis — 파이썬 바이트 코드 역 어셈블러 — Python 3.11.0a7 문서

dis — 파이썬 바이트 코드 역 어셈블러 소스 코드: Lib/dis.py dis 모듈은 CPython 바이트 코드를 역 어셈블 하여 분석을 지원합니다. 이 모듈이 입력으로 취하는 CPython 바이트 코드는 파일 Include/opcode.h

docs.python.org

 

 

파이썬 컴파일 옵션

https://docs.python.org/ko/dev/library/compileall.html

 

compileall — 파이썬 라이브러리 바이트 컴파일하기 — Python 3.11.0a7 문서

compileall — 파이썬 라이브러리 바이트 컴파일하기 소스 코드: Lib/compileall.py 이 모듈은 파이썬 라이브러리 설치를 지원하는 몇 가지 유틸리티 함수를 제공합니다. 이 함수는 디렉터리 트리에서

docs.python.org