Author: Maciej Fijalkowski <fij...@gmail.com> Branch: extradoc Changeset: r4120:7ccc9ce397fd Date: 2012-03-05 14:18 -0800 http://bitbucket.org/pypy/extradoc/changeset/7ccc9ce397fd/
Log: add pieces needed to compile diff --git a/talk/pycon2012/tutorial/Makefile b/talk/pycon2012/tutorial/Makefile new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/Makefile @@ -0,0 +1,10 @@ + + +slides.pdf: slides.rst author.latex title.latex stylesheet.latex + rst2beamer.py --input-encoding=utf-8 --output-encoding=utf-8 --stylesheet=stylesheet.latex --documentoptions=14pt --theme=Warsaw slides.rst slides.latex || exit + sed 's/\\date{}/\\input{author.latex}/' -i slides.latex || exit + sed 's/\\maketitle/\\input{title.latex}/' -i slides.latex || exit + pdflatex slides.latex || exit + +view: slides.pdf + evince slides.pdf & diff --git a/talk/pycon2012/tutorial/author.latex b/talk/pycon2012/tutorial/author.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/author.latex @@ -0,0 +1,7 @@ +\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} + +\title[PyPy]{How to get most out of your PyPy?} +\author[fijal]{Maciej Fijałkowski, Alex Gaynor, Armin Rigo} + +\institute{PyCon 2012} +\date{7 March 2012} diff --git a/talk/pycon2012/tutorial/beamerdefs.txt b/talk/pycon2012/tutorial/beamerdefs.txt new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/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/pycon2012/tutorial/examples/07_itertools.py b/talk/pycon2012/tutorial/examples/07_itertools.py new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/examples/07_itertools.py @@ -0,0 +1,23 @@ + +from itertools import imap, izip +import operator +import timeit + +vector1 = [i for i in range(10000)] +vector2 = [i for i in range(10000)] + +def one(vector1, vector2): + return sum(imap(operator.add, vector1, vector2)) + +def two(vector1, vector2): + return sum(x + y for x, y in izip(vector1, vector2)) + +def three(vector1, vector2): + s = 0 + for i in range(len(vector1)): + s += vector1[i] + vector2[i] + +print "one", timeit.timeit(lambda : one(vector1, vector2), number=1000) +print "two", timeit.timeit(lambda : two(vector1, vector2), number=1000) +print "three", timeit.timeit(lambda : three(vector1, vector2), number=1000) + diff --git a/talk/pycon2012/tutorial/slides.rst b/talk/pycon2012/tutorial/slides.rst --- a/talk/pycon2012/tutorial/slides.rst +++ b/talk/pycon2012/tutorial/slides.rst @@ -1,27 +1,33 @@ +.. include:: beamerdefs.txt + +================================= +How to get most out of your PyPy? +================================= + First rule of optimization? =========================== |pause| -If it's not correct, it doesn't matter. +* if it's not correct, it doesn't matter Second rule of optimization? ============================ |pause| -If it's not faster, you're wasting time. +* if it's not faster, you're wasting time |pause| -But if you iterate fast, you can afford wasting time +* but if you iterate fast, you can afford wasting time Third rule of optimization? =========================== |pause| -Measure twice, cut once. +* measure twice, cut once (C)Python performance tricks ============================ @@ -34,18 +40,18 @@ * ``append = my_list.append``, grab bound methods outside loop -* Avoiding function calls +* avoiding function calls -* Don't write Python +* don't write Python Forget these ============ * PyPy has totally different performance characterists -* Which we're going to learn about now +* which we're going to learn about now -* You cannot speak about operations in isolation (more later) +* you cannot speak about operations in isolation (more later) Why PyPy? ========= @@ -138,16 +144,16 @@ * JIT complete by design, as long as the interpreter is correct -* Only **one** language description, in a high level language +* only **one** language description, in a high level language -* Decent tools for inspecting the generated code +* decent tools for inspecting the generated code Performance characteristics - runtime ===================================== -* Runtime the same or a bit slower as CPython +* runtime the same or a bit slower as CPython -* Examples of runtime: +* examples of runtime: * ``list.sort`` @@ -162,32 +168,32 @@ Performance characteristics - JIT ================================= -* Important notion - don't consider operations in separation +* important notion - don't consider operations in separation -* Always working as a loop or as a function +* always working as a loop or as a function -* Heuristics to what we believe is common python +* heuristics to what we believe is common python -* Often much faster than CPython once warm +* often much faster than CPython once warm Heuristics ========== -* What to specialize on (assuming stuff is constant) +* what to specialize on (assuming stuff is constant) -* Data structures +* data structures -* Relative cost of operations +* relative cost of operations Heuristic example - dicts vs objects ==================================== -* Dicts - an unknown set of keys, potentially large +* dicts - an unknown set of keys, potentially large -* Objects - a relatively stable, constant set of keys +* objects - a relatively stable, constant set of keys (but not enforced) -* Performance example +* performance example Specialized lists ================= @@ -213,13 +219,13 @@ Obscure stuff ============= -* Frame access is slow +* frame access is slow -* List comprehension vs generator expression +* list comprehension vs generator expression -* Profiling & tracing hooks +* profiling & tracing hooks -* A bit in the state of flux +* a bit in the state of flux JitViewer ========= @@ -233,15 +239,15 @@ The overview ============ -* Usually three pieces per loop +* usually three pieces per loop -* Prologue and two loop iterations (loop invariants in the first bit) +* prologue and two loop iterations (loop invariants in the first bit) -* They contain guards +* they contain guards -* Guards can be compiled to more code (bridges) that jump back to the loop +* guards can be compiled to more code (bridges) that jump back to the loop or somewhere else -* Functions are inlined +* functions are inlined -* Sometimes completely twisted flow +* sometimes completely twisted flow diff --git a/talk/pycon2012/tutorial/stylesheet.latex b/talk/pycon2012/tutorial/stylesheet.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/stylesheet.latex @@ -0,0 +1,10 @@ +\usetheme{Warsaw} +\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/pycon2012/tutorial/title.latex b/talk/pycon2012/tutorial/title.latex new file mode 100644 --- /dev/null +++ b/talk/pycon2012/tutorial/title.latex @@ -0,0 +1,5 @@ +\begin{titlepage} +\begin{figure}[h] +\scalebox{0.8}{\includegraphics[width=80px]{../../img/py-web-new.png}} +\end{figure} +\end{titlepage} _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit