Why Python?

License

  • Python is free (free as in "free beer").
  • Pythonu (and libraries) have open source (free as in "free speech").
  • The license if permisive in using Python in closed source, commercial projects (unlike the viral GPL).
  • The Python software foundation (PSF) license is available http://docs.python.org/3/license.html.

Implications:

  • Lower costs (likely).
  • No license server, easy off-line use, no users wrangles.
  • Code portability and sharing -- anyone can install and use your programs (if you want to).
  • It's possible to discover how things work by inspecting the source code (no black boxes).

Python is a universal programming language loaded with goodies

  • object oriented programming, functional prgramming
  • readable syntax
  • scalability: from a simple script to complex applications
  • automatic unit testing
  • easy code documenting
  • broad user base, available support (google, http://stackoverflow.com)
  • Python is a broadly wanted skill, in contrast to dedicated scientific languages (IDL, Matlab etc.) -- just look up job listings

Extensive set of scientific libraries

  • Numpy - vector/matrix algebra
  • Scipy - scientific functions
  • Matplotlib - interactive graphing with publication quality output
  • SymPy - symbolic manipulation

...

Universal library

  • Do you need to acquire data in a not so traditional manner (from the web or weird file format)?
  • Need a complex text procesing?
  • Need to write a GUI (and do not waste months)?
  • Need to implement a web interface?
  • Or send an email when your calculation is finished?
  • What about launching a subprocess and communicate via a pipe?

All these tasks can be handled very effectively in Python, often using only the standard library. This is often not the case in dedicated systems (Matlab, IDL, ...) or Fortran or C/C++.

See the PyPi package database, which contains tens of thousands packages (of diverse quality).

Binding to other languages

Because of the speed and existing libraries:

  • C/C++ (Python C API, module ctypes, Cython, SWIG, boost::python)
  • FORTRAN (f2py)

Also:

Tools

  • IPython - including the Jupyter Notebook
  • Sphinx - helps you create the documentation
  • pip, virtualenv - package and environment management

Downsides

  • It's difficult to distribute an application without external dependencies (a signle "EXE").
  • Limited static code analysis due to dynamic typing.
  • Genrally slow compared to compiled code. (We'll learn how to deal with this!)
  • Multithreading is very limited in CPython.
  • Matplotlib plot lack interactive tools compared to MATLAB.

Comments

Comments powered by Disqus