These tools are being used by large enterprise companies to service hundreds of millions of monthly users with stacks based on Python and Django. Companies like Instagram, Dropbox, and Yelp are 100% Python and manage to scale to handle on the order of 1 billion users.
Cython is an optimising static compiler for both the Python programming language and the extended Cython programming language (based on Pyrex). It makes writing C extensions for Python as easy as Python itself. Cython gives you the combined power of Python and C to let you:
In [1]:
# Pure Python Fibonacci example
def compute_fibonacci(n):
"""Computes fibonacci sequence"""
a = 1
b = 1
intermediate = 0
for x in range(n):
intermediate = a
a += b
b = intermediate
return a
In [2]:
# To enable support for Cython compilation, install Cython and load the Cython extension from within Jupyter Notebook:
%load_ext Cython
In [3]:
%%cython
# Cython version of Fibonacci example
cpdef int compute_fibonacci_cython(int n):
""" Compute the nth fibonacci number in a non-recursive fashion."""
cdef int a, b, intermediate, x
a = 1
b = 1
for x in range(n):
intermediate = a
a += b
b = intermediate
return a
In [4]:
N = 100
%timeit compute_fibonacci(N)
In [5]:
%timeit compute_fibonacci_cython(N)
In [6]:
6.36e-6/96.7e-9
Out[6]:
The typing module supports type hints. Type hints for function arguments and return types was added in Python 3.5. Type hints for local variables was added in Python 3.6.
Using type hints improves the readability and maintainability of code. Additionally, IDEs and static analysis tools can verify that the type hints are being complied with.
In [7]:
# The function below takes and returns a string and is annotated as follows:
def greeting(name: str) -> str:
return 'Hello ' + name
In [8]:
greeting('Todd')
Out[8]:
In [9]:
greeting(1)
Florida PyCon will be the first Saturday in October (2017-10-07) from 8AM to 5PM
The conference will be held in Orlando, FL at the Exchange downtown: Church Street Station Exchange 101 S Garland Ave Orlando, FL 32801
Recently I have been maintaining the cmd2 open-source Python library for rapidly developing interactive command-line applications. It can be used to easily create a full-featured shell with capabilities similar to Bash out-of-the-box.
I met with the original author at PyCon and got joint ownership of the PyPI account so that I can publish releases and users can install the latest version via pip.
You can learn more about cmd2 by reading the documentation. Or if you are like me, just go look at some of the examples on GitHub.
In [ ]: