시스템프로그래밍의 마지막 수업을 들으면서 링킹이 무엇인지 배워보았다.
C언어 베이스의 컴파일언어들은, 사용자가 작성한 코드, 가령 hello.c라는 파일이 있다면
(1) 전처리기(Preprocessor)를 통해 관련된 헤더파일이나 라이브러리의 함수들을 가지고 오며 hello.i 파일을 만든다.
(2) 만들어진 hello.i 파일을 컴파일러가 x 어셈블리어로 바꿔서 hello.s를 만든 후
(3) 어셈블리어가 x86이나 arm등의 기계의 아키텍쳐에 맞게 이를 바이너리코드인 오브젝트파일 hello.o로 바꾸고
(4) 최종적으로 링커의 링킹과정을 통해 주어진 object file들과 필요한 라이브러리를 취합해
실행가능(executable)한 object파일, 즉 hello.exe 을 만들어 낸다.
그렇다면 파이썬과 같은 인터프리터 언어는 executable 한 파일을 만들기 까지
어떠한 과정을 거칠까?
이전 같았으면 티스토리를 검색했겠지만,
이러한 학부수준의 질문은 Chatgpt 선생만으로도 충분하다는 믿음이 있어서 챗선생님한테 물어보았다.
The process of creating an executable file from a Python code file is a bit different than the process for a C code file. Here's a general overview of the process:
(1) Python code file: This is the source code file written in the Python programming language.
(2) Interpreter: The Python interpreter reads the source code file and executes the instructions. The Python interpreter is required to run the Python code on any platform.
(3) Compiler or Packager: There are several tools available to convert the python code into an executable file, such as PyInstaller, cx_Freeze, etc.
These tools package the Python interpreter and the source code together into a single executable file.
(4) Executable file: The resulting file is a standalone executable file that can be run on the target platform without requiring the Python interpreter to be installed.
Please note that the resulting executable file will be platform dependent, so you will need to create a different executable for Windows, Mac, and Linux. Also, Some of the libraries used by your code may not be compiled by default and will not work on the target machine.
Python에서 executable file을 만드는 방법은 C언어와 조금 다릅니다.
과정의 간략한 개요를 보도록 합시다.
(1) 파이썬 코드 파일 : 이것은 파이썬 프로그래밍 언어로 작성된 소스코드 파일입니다.
(2) 인터프리터 : 파이썬 인터프리터가 소스코드를 읽어들이고 명령문들을 수행합니다.
어떠한 플랫폼이든, 파이썬 인터프리터는 파이썬 코드를 수행하기 위해 필요합니다.
(3) 컴파일러나 패키져 : 이 것들은 파이썬 코드를 executable(.exe) 파일로 바꿔주는 몇몇 툴들입니다.
PyInstaller, cx_Freeze 등이 있습니다.
이러한 툴들은 파이썬 인터프리터와 소스코드를 하나로 합쳐서 하나의 exe파일로 만들어 줍니다.
(4) 실행가능한 파일(=.exe=executable) : 이렇게 만들어진 exe파일은 그 플랫폼 상에서 파이썬 인터프리터가 설치되지 않아도 실행가능하게 됩니다.
이렇게 만들어진 exe파일은 실행환경이 되는 플랫폼에 의존적이며, 윈도우, 맥, 리눅스등의 환경에 따라 각각의 exe파일을 만들어야 한다는 것을 주의하세요. 그리고 소스코드에 사용된 몇몇 라이브러리는 특정 머신에 따라
기본적으로 컴파일 되지 않을 수도 있습니다.
+
백준을 풀다가 Pypy라는 언어가 있길래 이것은 도당체 뭐하는데 쓰이는 언어일까.
해서 Chatgpt에 물어봤다.
파이썬3이랑 PyPy3은 뭔 차이여?
Q : what is difference btw python3 and pypy3?
Python3 and PyPy3 are both implementations of the Python programming language, but they have some key differences:
파이썬3과 PyPy3는 둘다 파이썬 프로그래밍 언어의 구현(Implementation, 뭔 단어인지 몰라서 밑에 한번 더 물어봄)이지만, 핵심적인 부분에서 차이가 있습니다.
Performance: PyPy3 is an alternative Python interpreter that is built using the RPython programming language. It is designed to be faster than the standard CPython interpreter, which is the reference implementation of Python. PyPy3 can be significantly faster than CPython for certain types of code, especially for code that makes heavy use of dynamic features such as dynamic attribute access or dynamic type operations.
퍼포먼스(수행시간) : PyPy3는 RPython 언어를 기반으로 만들어진 파이썬 인터프리터입니다.
얘네는 우리가 디폴트로 사용하는 Python이라는 언어를 구현(Implementation)하기 위해 쓰는 CPython 인터프리터보다 빠릅니다. Pypy3는 상황에 따라 CPython보다 훨씬 빠르게 코트를 수행할 수 있습니다. 특히 동적인 특징을 가진 코드들, 예를 들면 dynamic attribute access 나 dynamic type operations이 그렇습니다.
Compatibility: PyPy3 is compatible with most Python3 code, but it is not completely compatible with all Python3 code. Some third-party libraries and modules may not work correctly with PyPy3. This is because PyPy3 uses its own implementation of the Python runtime, which may not be identical to the implementation used by CPython.
호환성 : PyPy3는 대부분의 파이썬3코드들과 호환이 되지만, 완전히 호환되지는 않습니다. 몇몇 서드파티 라이브러리와 모듈들은 PyPy3에서 작동하지 않을 것입니다. 이는 PyPy3가 CPython과는 다른 독자적인 구현(Implementation) 방식을 사용하기 때문입니다.
Memory usage: PyPy3 is also generally more memory efficient than CPython, due to its more advanced garbage collector and other memory management features.
메모리사용 : PyPy3은 CPython보다 일반적으로는 메모리 효율성이 더 좋습니다. 더 뛰어난 가비지 컬렉팅 기능과 메모리 관리 특성이 있기 때문입니다.
Development: PyPy3 development is separate from the main Python development, which means it might not be up-to-date with the latest features and changes in Python3.
개발버젼 (*및 업데이트) : PyPy3는 Python이 최신 업데이트 버젼과 분리되어 있어서 Python3가 업데이트 되어도 바로바로 같이 최신버젼으로 업데이트 되지 않아 변화된 기능을 사용하지 못할 수도 있습니다.
Overall, PyPy3 can be a good choice if you are looking for improved performance and memory usage in your Python3 programs, but you should be aware that compatibility issues may arise.
요약하자면, PyPy3는 당신이 Python3를 수행할 때, 퍼포먼스와 메모리 관리를 원한다면 좋은 선택이 될 수 있으나, 발생할 수 있는 호환성 문제를 항상 조심해야 할 것입니다.
---
- 위키백과의 '구현'
컴퓨터 공학에서, Implementation(구현)이란 기술적으로 정리해놓은 규격서나 알고리즘을 프로그래밍 혹은 소프트웨어 배치를 통해 프로그램이나 소프트웨어의 부분, 다른 컴퓨터 시스템을 구축하는 것을 말한다. 하나의 규격서나 표준에도 다양한 구현이 있을 수 있다. 예를 들면, 웹 브라우저는 W3C에서 정한 규격서의 구현을 포함하고 있다. 또, 소프트웨어 개발 도구는 프로그래밍 언어의 구현을 포함하고 있다.
---
챗gpt에게 물어본 구현
이눔의 '구현,Implementation' 이 뭐시여?
Q : what does a 'implementation' mean in programming language?
In the context of programming languages, an implementation refers to a specific version or variation of a programming language that has been created and developed to conform to the language's specification.
프로그래밍 언어에서, Implementation이란 그 특정한 프로그래밍 언어(여기서 Python3)의 요구사항이나 표준 규격에 맞춰서 만들어진 특정 버전의 프로그래밍 언어를 의미합니다.
A programming language specification defines the syntax and semantics of the language, including the rules for how the language should be used, the types of data it can work with, and the set of operations that can be performed.
프로그래밍 언어의 Specification(규격)은 언어의 구문과 의미를 정의하며, 언어를 사용하는 방법, 그 언어가 처리할 수 있는 데이터 유형, 수행 가능한 연산등을 포함합니다.
An implementation, on the other hand, is a concrete, executable version of the language that can be run on a computer.For example, CPython is an implementation of the Python programming language, while PyPy is another implementation of Python.
반면에 Implementataion(구현)은 프로그래밍 언어의 구체적이고, 실행가능한 버젼으로, 컴퓨터상에서 실행이 가능합니다. 예를 들자면, CPython(Python 3)은 파이썬 프로그래밍 언어의 구현이지만, PyPy 또한 파이썬의 또다른 구현이라고 할 수 있습니다.
Both of them conform to the Python specification but they have different performance characteristics and might have different compatibility with certain libraries and modules.There can be multiple implementations of a programming language, each with its own strengths and weaknesses, and each targeting different platforms, hardware or use cases. Some programming languages may have multiple widely used implementations, while others may have only one widely used implementation.
둘다 파이썬이라는 언어의 규격을 충족하지만, 둘은 다른 퍼포먼스적인 특성을 가지고, 몇몇 라이브러리나 모듈이 호환되지 않을 수 있습니다. 프로그래밍 언어에는 여러가지의 '구현'이 존재할 수 있으며, 각각의 '구현'들은 저마다 강점과 약점을 가지고 목표가 되는 플랫폼(*예를 들면 윈도우 or 리눅스)이나 하드웨어(*예를 들면 x86이나 ARM)이 다를 수도 있습니다. 일부 프로그래밍 언어들은 여러가지의 구현들을 다 쓰까쓰기도 하지만, 일부 프로그래밍 언어들은 오직 하나의 구현만을 사용하기도 합니다.
---
'구현,Implemenation'이란 단어가 참 애매하다
결국 추상적인 언어를 수행하기 위해 만들어진
더 실체적인 프로그램이나 프로그램의 버젼의 개념이다.
하 슈발... 내가 컴공을 갔으면, 오토마타와 프로그래밍 언어 수업을 듣고 완벽히 배웠을 텐데
'거대한 정보의 더미들 > 파이썬 코딩테스트 정리' 카테고리의 다른 글
230116 프로그래머스 코딩테스트 기초 100제 체크포인트 (1) | 2023.01.22 |
---|---|
파이썬의 모듈과 라이브러리의 차이 + Compiler Flag + Identifier(식별자) (0) | 2023.01.22 |
230112 일기0 개발공부를 시작하며 (0) | 2023.01.21 |
220112 깃헙 사용법 (0) | 2023.01.12 |
221200 c++ 강의 들으면서 적은 체크포인트들 (0) | 2022.12.27 |