In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to compile Python source code, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
In a computer language, the Python source code is generally not compiled, but can be used through a few files.
We typically run a python program with a command like this:
C:\ > python im.py
The contents of the im.py file are:
#! / usr/bin/env python import mymodule mymodule.say ("hello")
After executing this command, the Python interpreter does not necessarily read the mymodule.py file, it attempts to read the mymodule.pyc file or the mymodule.pyo file. If they all fail, or if the mymodule.py file is newer than mymodule.pyc/mymodule.pyo, read the mymodule.py file instead.
Python only knows how to interpret and execute bytecode, so the first thing to do when a mymodule.py file is read is to compile it. The result of the compilation is attempted to be saved to the mymodule.pyc file. We will discuss how to control the compilation of Python in a moment.
Although the term compile is used in static languages like C++/Java, the actual situation is different. First of all, the most obvious point is that the end result of Python source code compilation is not machine code, but bytecode. The compilation of Python is actually mainly about grammar parsing, generating an abstract syntax tree, and then dumping it into bytecode form.
From the above introduction, we can see that the compilation of Python is very different from that of C++. However, it is somewhat similar to Java in that they both generate bytecode. In all conscience, the compilation process of Java is much more advanced than Python. When executing Java bytecode, Java's interpreter uses JIT to convert hot spots such as loop operations into machine code. So sometimes the performance of Java can reach a level close to C++.
Python's lack of JIT is not intentional, but a lack of human resources. There is already an external module for pysco, which is said to greatly improve the speed of Python code, but this module has not yet entered the official code of Python.
After reading the above, do you know how to compile the Python source code? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.