Why I lied when I said that Python does not have a compiler

Published: 28 August 2024
on channel: Python for Everyone
139
14

In this video you learn what a compiler does and the answer to this important question: Does Python have a compiler?

Source code written by us developers, needs to be converted to executable programs. For this, there are two common techniques. A compiler can process the source code and generate an executable program for a specific architecture like arm, x86 or an Apple M-processor. When programs are compiled for specific architectures, static types can be used to optimize performance. For example, the compiler can decide to use hardware acceleration for specific operations.

There is also a downside of course and that is that programs have to be compiled for each platform and architecture. The resulting binaries cannot be exchanged between platforms. An alternative is to create some kind of virtual machine for each platform. This way the same source code can be used to feed each virtual machine, regardless of the platform it is running on. The Python interpreter functions as a virtual machine and does even more.

"pyc" means python compiled. Yep. Python does have a compiler to create byte-code. The byte-code is compiled for the interpreter that was used to execute the script. So what happens if this exact project is run on another Python configuration?


Watch video Why I lied when I said that Python does not have a compiler online, duration hours minute second in high quality that is uploaded to the channel Python for Everyone 28 August 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 139 times and liked it 14 visitors.