Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Python Implementation" vs. "Python distribution" vs. Python itself?

New to Python world. What is the difference between "Python Implementation" vs. "Python distribution" vs. Python itself? for example:

  • I can download Python itself (Python 3.4.2) from python.org/downloads/release/python-342/
  • OR there is an "implementation" "nicknamed CPython" I can get from python.org/download/alternatives/
  • OR I can use a "distribution" from wiki.python.org/moin/PythonDistributions

What are the differences? Can I use all at the same time? This lingo is not really elaborated upon.

like image 920
Kardo Paska Avatar asked Dec 12 '14 18:12

Kardo Paska


People also ask

What is a Python distribution?

A distribution of Python is a bundle that contains an implementation of Python along with a bunch of libraries or tools. In theory, a distribution of Python could use any implementation, although all the ones I know of use CPython.

Which Python distribution is best?

Based on the open source Conda packaging system, Anaconda is the best Python distribution I have found till now. For one, it comes with all the scientific libraries like numpy, scipy etc preinstalled, so you don't have to worry about messing with compiling them yourself.


3 Answers

"Python itself" is sort of a platonic ideal. Roughly speaking it is a specification, although there is no "real" specification as there is for some other languages like C. The behavior of Python the language is defined by the documentation available on python.org. Anything that does what that documentation says it's supposed to do would "count" as being Python.

An implementation of Python is an actual program that provides that behavior. The most common one is CPython, which is what you download from python.org. The other implementations found on the "alternatives" page you mentioned are other programs that also "count as Python" in that they give the documented behavior (sometimes with some caveats), but are written independently and may, for instance, run on other platforms, run faster, run slower, do things differently under the hood, etc.

A distribution of Python is a bundle that contains an implementation of Python along with a bunch of libraries or tools. In theory, a distribution of Python could use any implementation, although all the ones I know of use CPython. The download from python.org could also be considered a distribution (a minimal distribution that doesn't contain any "extras").

You could think of it by analogy to some sort of physical machine, say an oven. "Python itself" or "Python the language" is like a description of what that machine does: it heats up, you can turn a dial to set the temperature, etc. You can't use the description to cook anything; you have to build an actual oven first. An implementation of Python would be like an actual oven that you built; as long as it does what an oven is supposed to do, it is an oven, but there could be many ways of building an oven that does the right things (wood-fired, gas-fired, solar-powered, etc.). A distribution would be an oven that comes with other things that you might often want to use along with it --- like maybe a fully-equipped kitchen that includes pots, pans, spatula, and mixing bowls as well as the oven itself.

You can indeed use all three at the same time, and in some sense you kind of have to. There is no way to use "Python the language" without using an implementation of it; it would be like saying you want to "drive a car" without driving any particular kind of car. Likewise, you can't really use an implementation without getting it as part of a distribution (at least if you consider the "bare" python.org downloads to be a distribution too).

In practice, most people using Python for practical purposes are using CPython (the de facto standard implementation), so the real choice is among different distributions of that. Among those, you mainly choose based on what extras you want to come with it. You can choose to use the "bare" distribution from python.org and then install packages yourself, or if you plan on doing scientific/analytics computing, you could choose one of the distributions geared towards that (e.g., Anaconda or Canopy).

like image 107
BrenBarn Avatar answered Oct 16 '22 18:10

BrenBarn


Python itself is a programming language. It has various implementations which allow you to run programs written in it. To give you a better idea, msvc, clang, gcc are implementations of C. Here are some python implementations:

  • CPython: this is the default, and what you should be using if you have no idea.
  • Jython: implementation in java, allows you to use the java api.
  • IronPython: implementation for .net, allows you to use the .net api.
  • PyPy: JIT implementation.

A distribution is a python implementation bundled with some packages. If again, you have no idea about this, just use vanilla python, aka the default download.

like image 30
simonzack Avatar answered Oct 16 '22 19:10

simonzack


When most people loosely talk about "Python itself" they mean "a base Python system"—i.e. the interpreter and standard toolbox—as distinct from any third-party toolboxes. For example, you might say, "to run my Python-based software you will need to have installed Python itself, and also the third-party toolbox NumPy from numpy.org". The former is the conventional minimum for getting as far as "hello world" and the latter adds on more-specialized functionality.

A "distribution" is a "bunch of files that you download". A particular "Python distribution" may contain just a particular version of "Python itself" (like the distributions you get from python.org). Or it may be more inclusive: to save their users the separate effort of installing third-party dependencies, many people release "Python distributions" that contain more than just the base system. For example, they might supply a distribution that already include popular third-party packages like NumPy and SciPy (examples: distributions by WinPython, PortablePython, Enthought, Anaconda....)

As for the phrase "Python implementation": as other answerers have already mentioned, that is usually employed to emphasize the fact that a particular Python distribution differs from others in the way the interpreter has been coded "under the hood". The official python.org offerings are implemented in C, hence "CPython". There are also Python implementations made with Java. To wrap up all your terms together, you could download the PyPy distribution, which is a Python implementation written in "Python itself" ;-)

like image 41
jez Avatar answered Oct 16 '22 18:10

jez