Book Image

Learning IPython for Interactive Computing and Data Visualization, Second Edition

By : Cyrille Rossant
Book Image

Learning IPython for Interactive Computing and Data Visualization, Second Edition

By: Cyrille Rossant

Overview of this book

Python is a user-friendly and powerful programming language. IPython offers a convenient interface to the language and its analysis libraries, while the Jupyter Notebook is a rich environment well-adapted to data science and visualization. Together, these open source tools are widely used by beginners and experts around the world, and in a huge variety of fields and endeavors. This book is a beginner-friendly guide to the Python data analysis platform. After an introduction to the Python language, IPython, and the Jupyter Notebook, you will learn how to analyze and visualize data on real-world examples, how to create graphical user interfaces for image processing in the Notebook, and how to perform fast numerical computations for scientific simulations with NumPy, Numba, Cython, and ipyparallel. By the end of this book, you will be able to perform in-depth analyses of all sorts of data.
Table of Contents (13 chapters)
Learning IPython for Interactive Computing and Data Visualization Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing C in Python with Cython


Cython is a Python library that lets you combine C and Python in various ways. There are two main use-cases:

  • Wrapping a C/C++ library in Python

  • Optimizing your Python code by statically compiling it to C

In this section, we will demonstrate the second use-case. You will find an example of the first use-case in the IPython Cookbook and at http://docs.cython.org/src/tutorial/index.html.

Installing Cython and a C compiler for Python

If you use Anaconda, you should already have Cython (you can always do conda install cython to check).

For Cython to work, you need a C compiler compatible with your version of Python. This is much easier on Unix systems. Here are the instructions given at http://docs.cython.org/src/quickstart/install.html:

  • On Linux, you can install the GNU C Compiler (gcc) via the OS package manager. On Ubuntu or Debian, for example, type sudo apt-get install build-essential.

  • On Mac OS X, you can install Apple's Xcode from http://developer.apple.com.

  • On...