Author: Matti Picus <[email protected]> Branch: extradoc Changeset: r5638:8dca1d8207b6 Date: 2016-04-28 09:50 +0300 http://bitbucket.org/pypy/extradoc/changeset/8dca1d8207b6/
Log: add a talk diff --git a/talk/pycon-il-2016/Makefile b/talk/pycon-il-2016/Makefile new file mode 100644 --- /dev/null +++ b/talk/pycon-il-2016/Makefile @@ -0,0 +1,13 @@ +# pip install rst2beamer + +# WARNING: to work, it needs this patch for docutils +# https://sourceforge.net/tracker/?func=detail&atid=422032&aid=1459707&group_id=38414 + +talk.pdf: talk.tex + pdflatex talk.tex + + +talk.tex: talk.rst author.latex stylesheet.latex + rst2beamer --stylesheet=stylesheet.latex --documentoptions=14pt --input-encoding=utf8 --output-encoding=utf8 $< > talk.tex + sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit + diff --git a/talk/pycon-il-2016/author.latex b/talk/pycon-il-2016/author.latex new file mode 100644 --- /dev/null +++ b/talk/pycon-il-2016/author.latex @@ -0,0 +1,9 @@ +\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} + +\title[PyPy 2016]{PyPy 2016} +\author[mattip] +{Matti Picus\\ +\includegraphics[width=80px]{../img/py-web-new.png}} + +\institute{Scipy Israel 2016} +\date{May 2nd, 2016} diff --git a/talk/pycon-il-2016/beamerdefs.txt b/talk/pycon-il-2016/beamerdefs.txt new file mode 100644 --- /dev/null +++ b/talk/pycon-il-2016/beamerdefs.txt @@ -0,0 +1,108 @@ +.. colors +.. =========================== + +.. role:: green +.. role:: red + + +.. general useful commands +.. =========================== + +.. |pause| raw:: latex + + \pause + +.. |small| raw:: latex + + {\small + +.. |end_small| raw:: latex + + } + +.. |scriptsize| raw:: latex + + {\scriptsize + +.. |end_scriptsize| raw:: latex + + } + +.. |strike<| raw:: latex + + \sout{ + +.. closed bracket +.. =========================== + +.. |>| raw:: latex + + } + + +.. example block +.. =========================== + +.. |example<| raw:: latex + + \begin{exampleblock}{ + + +.. |end_example| raw:: latex + + \end{exampleblock} + + + +.. alert block +.. =========================== + +.. |alert<| raw:: latex + + \begin{alertblock}{ + + +.. |end_alert| raw:: latex + + \end{alertblock} + + + +.. columns +.. =========================== + +.. |column1| raw:: latex + + \begin{columns} + \begin{column}{0.45\textwidth} + +.. |column2| raw:: latex + + \end{column} + \begin{column}{0.45\textwidth} + + +.. |end_columns| raw:: latex + + \end{column} + \end{columns} + + + +.. |snake| image:: ../../img/py-web-new.png + :scale: 15% + + + +.. nested blocks +.. =========================== + +.. |nested| raw:: latex + + \begin{columns} + \begin{column}{0.85\textwidth} + +.. |end_nested| raw:: latex + + \end{column} + \end{columns} diff --git a/talk/pycon-il-2016/speed.png b/talk/pycon-il-2016/speed.png new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..63b771ce59358bbcb28efbba84a43f03328b4554 GIT binary patch [cut] diff --git a/talk/pycon-il-2016/stylesheet.latex b/talk/pycon-il-2016/stylesheet.latex new file mode 100644 --- /dev/null +++ b/talk/pycon-il-2016/stylesheet.latex @@ -0,0 +1,9 @@ +\setbeamercovered{transparent} +\setbeamertemplate{navigation symbols}{} + +\definecolor{darkgreen}{rgb}{0, 0.5, 0.0} +\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor} + +\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\red}[1]{\color{red}#1\normalcolor} diff --git a/talk/pycon-il-2016/talk.rst b/talk/pycon-il-2016/talk.rst new file mode 100644 --- /dev/null +++ b/talk/pycon-il-2016/talk.rst @@ -0,0 +1,252 @@ +.. include:: beamerdefs.txt + +========= +PyPy 2016 +========= + +Introduction +------------ + +Python is + +* A syntax or two + +* An interpreter + +* A set of standard libraries shipped with the interpreter + +* A vibrant number of communitis that shares code + +PyPy +---- + +* PyPy is an interpreter written in RPython + +* Speed is one of its main advantages + +* Compatible (mostly) + +Speed +----- + +.. image:: speed.png + :scale: 50% + :align: center + +How ? +----- + +* Tracing Just-In-Time compiler + +* Optimizes loops + +* Traces one iteration of a loop + +* Produces a linear trace of execution + +* Inlines almost everything + +* The trace is then optimized and compiled + +* Removes overhead + +Prove It +-------- + +Techniques to achieve performant Python +--------------------------------------- + +* Write better code + + - string concatenation + + - attribute lookup + +* Rewrite your code in C + +* Rewrite your code in Cython + +* Add accelators like Numba + +* Use PyPy + +Why not PyPy? +------------- + +* Python III + +* Third-party library support + +PyPy and C (1/2) +---------------- + +* PyPy and CFFI + +* CFFI is the easiest tool to I've used so far + +* Very fast on PyPy, fast enough on CPython + +* Used by NumPyPy + +* Use CFFI to call python from C + + - This means you can create your own C API in pure Python ! + +PyPy and C (2/2) +---------------- + +* CFFI enables embedded Python (and PyPy) in a C application (uWSGI) + +* What about C-API (glad you asked) + +* Actively worked on right now + +Python C API +------------ + +* Leaks way too many implementation details (refcounting, PyObject structure fields) + +* Makes it hard to improve Python while supporting 100% of the API + +* PyPy 5.0 introduced a major rewrite + +* Hint - good things are coming + +NumPyPy +------- + +* https://bitbucket.org/pypy/numpy + pypy + +* I have been working on it since 2011 + +* Replaces ndarray, umath with builtin modules + +* ~85% of the numpy tests are passing, on all platforms + +* Most of numpy is there: object dtypes, ufuncs + +* linalg, fft, random all via cffi + +NumPyPy performance +------------------- + +* Should be as fast as Numpy, faster for smaller arrays + +* Lazy evaluation ? + +* But what about SciPy? + +PyMetabiosis +------------ + +* https://github.com/rguillebert/pymetabiosis + +* Work in progress + +* Allows you to use any CPython module on PyPy (scipy for example) + +* Embeds CPython into PyPy with CFFI + +* Numpy arrays can be shared between PyPy and CPython + +PyMetabiosis +------------ + +|scriptsize| + +.. sourcecode:: python + + from pymetabiosis import import_module + + cpython_virtualenv_path = + "/tmp/venv/bin/activate_this.py" + + builtin = import_module("__builtin__") + + # Activate a virtualenv for the cpython interpreter + builtin.execfile(cpython_virtualenv_path, + {"__file__" : cpython_virtualenv_path} + ) + + pylab = import_module("matplotlib.pylab") + + pylab.plot([1, 2, 3, 4]) + pylab.show() + +|end_scriptsize| + +JitPy +----- + +* http://jitpy.readthedocs.io + +* Proof of concept (Maciej Fijałkowski) + +* Embeds PyPy into CPython + +* Provides a decorator that allows you to run specific functions on PyPy + +* Is used the same way as numba, but different performance characteristics + + +JitPy +----- + +|scriptsize| + +.. sourcecode:: python + + import numpy as np + from jitpy import setup + setup('<path-to-pypy-home>') + from jitpy.wrapper import jittify + + @jittify(['array', float], float) + def f(a, s): + r = 0 + for i in xrange(a.shape[0]): + r += a[i] * s + return s + func(np.arange(10000), 1.2) + +|end_scriptsize| + +Future - wouldn't it be great if +-------------------------------- + +* Improved C extension compatibility + +* Native Numpy + Scipy + ... + + +The Future is Now! +------------------ + +* (Applause) + +* Native numpy (tweaked) passes 90% of tests + +* How to leverage the JIT? + +Why this makes sense +-------------------- + +* Advantages and disadvantages of RPython + +* Advantages of a JIT (vectorization) + +* Leveraging this for other dynamic languages + +Takeaway +-------- + +* Get PyPy at pypy.org (or from your favorite distribution) + +* Try it + +* Give us feedback (good or bad) + +Thank You +--------- + +Questions ? _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
