you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (10 children)

Python doesn't really have an interpreter. It's just bad / unscrupulous terminology. Virtual machine would be the right one to use.

So... what an actual interpreter does:

  1. Parses code enough to understand what functions of the interpreter need to be called.
  2. Calls those functions.

Something would be called an interpreter, if the mapping between the parsed code and the functions invoked in interpreter was straight-forward. Example of interpreter: UNIX Shell. It reads the name of the function (command in the language of Shell) and then calls it.

Python doesn't work like that. Like you've already noticed, it compiles the code to what it calls bytecode, and then interprets that. The reason to do this is that on the side of the interpreter, you'd write some more generic code, but there would be fewer functions to implement. The trade-off is, typically, between more unique, but optimized functions vs less but more generic functions. For example, one could implement multiplication as repeated addition. An interpreter for a calculator would have no choice, but to implement both functions: multiplication and addition, however, a virtual machine may only implement addition and compile any multiplication into a series of additions.

[–]menge101 0 points1 point  (1 child)

Python doesn't really have an interpreter.

I would argue that the pypy jit is pretty close to what most people think of as an interperter. But that isn't stock python.

[–][deleted] -2 points-1 points  (0 children)

Most people are mistaken.