Title. Explain language performance is poor, why a language can not have both compilers and interpreters? This allows you to compile it when performance is required.
I'm just starting to get involved in computer science, engineering, light spraying ...
Reply content:
CPython is compiled into bytecode, see PYc file. Other Jpython,ironpython are also compiled into specific bytecode. PyPy can also be further JIT compiled into machine code.
The main performance problem is not the compilation, which is caused by the dynamic type system and various additional abstractions. The main question is to ask 2c-python-2c.py.
This static compiler?
A similar brain hole is of course impossible for only one person to open. Look, there's Nuitka.
, the author is also excited: Static Compilation-that is the point.
<-please combine the context to see: A static Python compiler? What ' s the point?
Other Brain Movement please refer to the list on the Python website wiki: pythonimplementations
I'm glad to tell you that Python is not a purely explanatory language. What we call the Python interpreter is actually CPython, and at the time of execution, Python will first compile the. py file into an intermediate form of bytecode (bytecode) and place it in memory, and then interpret the bytecode as a machine-readable binary code when it executes.
By default, the byte code compiled by the import file is saved, that is, the. pyc file we see. Of course we can show the compilation of A. py file and save it.
The static language compiles a binary file, which means that, since the end of the compilation, executing the file, the machine how to run is already determined the good thing.
And Python is a dynamic language, such as statement A+b, before executing it, you do not know what A and B are, is to perform integer operations? or floating-point arithmetic? You know, a general computer, which performs integer operations and floating-point arithmetic, is not the same.
So, dynamic language How do you go about fully compiling it? Python has done a great job.
If you are a more pure python, and you don't have too many third-party libraries, consider using the PyPy interpreter. But PyPy's support for most third-party libraries is inadequate. For example, the powerful Scientific computing library NumPy is not supported, of course, the support of the day than not too long.
Moreover, most of the speed bottlenecks are not related to language, but to algorithms. Not really, consider using C + + or Cuda acceleration is kingly.
The first time code so many words, really tired ....
Update:
@kalam Yum mentions that NumPy has a dedicated pypy version, and the official web site does provide download links. But the support is not enough Ah, want to come down and use it, found that it is not down, it seems that I this rotten network reason. For the time being I will not consider using PyPy.
There are also online references to ways to combine CPython and PyPy:
https:// github.com/fijal/jitpy
You can look at it without trying.
At present, it is still the sentence:
It is the kingly way to use C + + or cuda acceleration.
It is the kingly way to use C + + or cuda acceleration.
It is the kingly way to use C + + or cuda acceleration.
Learn python at the same time, learn C + + and Cuda, why not? Because Python is a dynamic language. Many attributes depend on the program metadata. So even if compiled into machine code, still need to take the runtime, garbage collector, the program itself metadata. Compiling the machine code might improve performance in terms of numerical operations, but other aspects may not have a significant performance boost.
Compiled into machine code, in fact, similar to the PyPy kind of JIT, just to save the results of the compilation. In fact, in addition to scientific calculations, most of the scenarios used in Python do not care about its performance. (Shake a clever
Cython:c-extensions for Python
You mean this? Python is not a purely interpretive language, so it can be thought of as a compiler in the general sense of its so-called interpreter. This question is like why a horse is not as comfortable lying as a person sleeping.