흔히 "python 은 interpreted language다"라고들 배운다. 그러나 이 문장은 틀린 문장이다. 특정 프로그래밍 언어는 interpretor를 사용하거나, compiler를 사용하거나, 둘 다 사용하여 실행될 수 있다.


"Python"으로 알려진 일반적인 버전은 사실 CPython으로써, 실행될 경우 .pyc의 확장자를 가진 bytecode로 compile된다. 그 후 이 .pyc 파일은 interpreter로 알려진 virtual machine (CPython VM, Java VM 등)에 의해 기계어로 interpret된다.


이는 Java와 유사한 방식으로, python또한 interpretor와 compiler를 함께 사용한다고 볼 수 있다. Java와의 차이점은 CPython의 compile은 매우 간략하여 Java compiler보다 오류에 느슨하다는 점이다.


[출처] https://stackoverflow.com/questions/2998215/if-python-is-interpreted-what-are-pyc-files


+ Recent posts