Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning IPython for Interactive Computing and Data Visualization, Second Edition

You're reading from   Learning IPython for Interactive Computing and Data Visualization, Second Edition Get started with Python for data analysis and numerical computing in the Jupyter notebook

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783986989
Length 200 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Cyrille Rossant Cyrille Rossant
Author Profile Icon Cyrille Rossant
Cyrille Rossant
Arrow right icon
View More author details
Toc

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime