What does a Python interpreter do?
Is Python interpreted, or compiled, or both? - Stack Overflow
Updating Python interpreter over and over : pycharm
What ever happened to the Python interpreter for the 3DS?
The tech demo is available for anyone to download: https://github.com/MarcuzD/PyShell27/releases
The wrappers for CTRULIB and SF2DLIB aren't implemented, however. They might not be in the near future, as MarcusD moves on to other projects. However, it shouldn't be too hard to make your own wrappers with SWIG or the C-Python API or something like that. If you're lucky, someone else might release wrappers in the near future to use with the interpreter.
More on reddit.comVideos
I’ve been trying to understand exactly what an interpreter does, and how it’s different from a compiler.
From my understanding:
Python converts the code to bytecode, and then the Python Virtual Machine/interpreter executes the script line for line checking for errors.
Is that accurate? What exactly is the role of an interpreter? Also, does the PVM not need the code to be in machine language to understand it?
First off, interpreted/compiled is not a property of the language but a property of the implementation. For most languages, most if not all implementations fall in one category, so one might save a few words saying the language is interpreted/compiled too, but it's still an important distinction, both because it aids understanding and because there are quite a few languages with usable implementations of both kinds (mostly in the realm of functional languages, see Haskell and ML). In addition, there are C interpreters and projects that attempt to compile a subset of Python to C or C++ code (and subsequently to machine code).
Second, compilation is not restricted to ahead-of-time compilation to native machine code. A compiler is, more generally, a program that converts a program in one programming language into a program in another programming language (arguably, you can even have a compiler with the same input and output language if significant transformations are applied). And JIT compilers compile to native machine code at runtime, which can give speed very close to or even better than ahead of time compilation (depending on the benchmark and the quality of the implementations compared).
But to stop nitpicking and answer the question you meant to ask: Practically (read: using a somewhat popular and mature implementation), Python is compiled. Not compiled to machine code ahead of time (i.e. "compiled" by the restricted and wrong, but alas common definition), "only" compiled to bytecode, but it's still compilation with at least some of the benefits. For example, the statement a = b.c() is compiled to a byte stream which, when "disassembled", looks somewhat like load 0 (b); load_str 'c'; get_attr; call_function 0; store 1 (a). This is a simplification, it's actually less readable and a bit more low-level - you can experiment with the standard library dis module and see what the real deal looks like. Interpreting this is faster than interpreting from a higher-level representation.
That bytecode is either interpreted (note that there's a difference, both in theory and in practical performance, between interpreting directly and first compiling to some intermediate representation and interpret that), as with the reference implementation (CPython), or both interpreted and compiled to optimized machine code at runtime, as with PyPy.
The CPU can only understand machine code indeed. For interpreted programs, the ultimate goal of an interpreter is to "interpret" the program code into machine code. However, usually a modern interpreted language does not interpret human code directly because it is too inefficient.
The Python interpreter first reads the human code and optimizes it to some intermediate code before interpreting it into machine code. That's why you always need another program to run a Python script, unlike in C++ where you can run the compiled executable of your code directly. For example, c:\Python27\python.exe or /usr/bin/python.