The Many Faces of Python
The word "Python" encompasses a variety of meanings (even within this narrow context of programming). First, Python is a programming language with a defined syntax and specification. When referring to the language, we will capitalize the name as "Python". But python
is also a program, namely the default CPython interpreter that processes Python source code and serves as the reference implementation. When referring to the interpreter, we will write its name in lowercase as "python".
Over time, the word "Python" has also come to imply a rich ecosystem of libraries and tools that facilitate the construction of programs. It turns out that even though much of the ecosystem is written in Python, a lot of it is written in other programming languages and wrapped up so as to be callable from within the python interpreter. In cases where useful functionality is being provided by tools in the larger Python ecosystem outside of the core language, we will make that clear. And while we are focused here on a niche within that ecosystem that supports scientific computing, there are other niches developed and used by different communities to support other realms of activity (in web programming, image processing, natural language processing, etc.).
In similar fashion, interpreters that can run Python programs have moved well beyond the original CPython. For interactive use and code development, the
IPython (Interactive Python) interpreter — which runs on top of CPython —
offers increased functionality for a number of
tasks, including profiling
and timing the performance of different parts of your code. (When the IPython package is installed, the interpreter can be started up on the command line via ipython
.) Jupyter notebooks, which originally grew out of IPython, provide a browser-based environment for integrating live Python/IPython code with analysis results, graphics, and documentation. For running production codes, though, you are still likely to use the basic python program. In batch jobs, you might run your program from the command line with a command like python my_program.py
, or through an executable version of a python script beginning with a line such as #!/usr/bin/env python
. Beyond CPython/IPython/Jupyter, there are alternative interpreters developed by the community (written in Java, C#, Python, etc.), but those efforts are outside of the scope of this tutorial. We will focus here on techniques for performance using CPython-based systems, which are the most widely used.
Python 3 is the officially supported version of the language, with Python 2 having reached EOL (End of Life) status and thus receiving no further official support from the Python Software Foundation. Python version 2.7 is still installed by default on many Linux and Mac systems, because it is used for various system administration tasks. But you should not rely on that installation for your own work, should not install additional packages to work with that installed version, and should be working to migrate to Python 3 if you have not already done so. (We provide additional information later in this tutorial about Python installations and distributions available for you to use.) See What's New in Python for more information about what language and library features have changed over time. Links to Python documentation at python.org presented here are to the latest Python 3.x version, but those web pages all provide a selectable option to view documentation associated with other versions.