[pypy-commit] extradoc extradoc: talk as it went

fijal noreply at buildbot.pypy.org
Sat Oct 6 12:51:41 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: extradoc
Changeset: r4836:7648e9939155
Date: 2012-10-06 12:51 +0200
http://bitbucket.org/pypy/extradoc/changeset/7648e9939155/

Log:	talk as it went

diff --git a/talk/pyconza2012/examples/alloc.py b/talk/pyconza2012/examples/alloc.py
--- a/talk/pyconza2012/examples/alloc.py
+++ b/talk/pyconza2012/examples/alloc.py
@@ -3,14 +3,14 @@
 
 def f():
     l = [None]
-    for i in range(int(sys.argv[1])):
+    for i in xrange(int(sys.argv[1])):
         l[0] = (i,)
 
 def g():
     m = int(sys.argv[1])
     l = [None] * m
-    for i in range(m):
-        l[i] = i
+    for i in xrange(m):
+        l[i] = (i,)
 
 t0 = time.time()
 f()
diff --git a/talk/pyconza2012/examples/calls.py b/talk/pyconza2012/examples/calls.py
--- a/talk/pyconza2012/examples/calls.py
+++ b/talk/pyconza2012/examples/calls.py
@@ -30,7 +30,7 @@
     count = int(sys.argv[1])
     t0 = time.time()
     o = A()
-    for i in range(count):
+    for i in xrange(count):
         func(i, i, o)
     tk = time.time()
     t = (tk - t0) / count
diff --git a/talk/pyconza2012/examples/interpreter.py b/talk/pyconza2012/examples/interpreter.py
--- a/talk/pyconza2012/examples/interpreter.py
+++ b/talk/pyconza2012/examples/interpreter.py
@@ -9,6 +9,9 @@
         # try right
         return right.radd(left)
 
+    def radd(self, left):
+        raise TypeError
+
 class Long(BaseObject):
     pass
 
@@ -22,6 +25,8 @@
                 return Integer(self.intval + right.intval)
             except OverflowError:
                 return Long(self.intval).add(Long(right.intval))
+        else:
+            return right.radd(self)
 
 def interpret(bytecode, variables, constants):
     stack = []
@@ -55,3 +60,13 @@
             pos = arg0
             continue
         pos += 1
+
+
+def f(a, b):
+    return a + b
+
+stack.append(variables[arg0])
+stack.append(variables[arg0])
+right = stack.pop()
+left = stack.pop()
+stack.append(left.add(right))
diff --git a/talk/pyconza2012/talk.pdf b/talk/pyconza2012/talk.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..8eb88f4bb2440dcede688672bdf6b31b30be2d4d
GIT binary patch

[cut]

diff --git a/talk/pyconza2012/talk.rst b/talk/pyconza2012/talk.rst
--- a/talk/pyconza2012/talk.rst
+++ b/talk/pyconza2012/talk.rst
@@ -16,24 +16,79 @@
 What this talk is about?
 ------------------------
 
-* I'll start where Larry finished
+* python performance (or lack of it)
 
-* describe a bit how the PyPy JIT works
+* why does it matter
 
-* what's the difference between interpretation and JIT compilation
+* what can we do about it
+
+* how PyPy works
+
+Python performance message
+---------------------------
+
+* according to Guido
+
+* "Avoid overengineering datastructures. Tuples are better than objects (try namedtuple too though). Prefer simple fields over getter/setter functions."
+
+* "Built-in datatypes are your friends. Use more numbers, strings, tuples, lists, sets, dicts. Also check out the collections library, esp. deque."
+
+* "Be suspicious of function/method calls; creating a stack frame is expensive."
+
+* "The universal speed-up is rewriting small bits of code in C. Do this only when all else fails."
+
+What does it mean?
+------------------
+
+* don't use abstractions
 
 |pause|
 
-* show some assembler
+* don't use Python
+
+But also
+--------
+
+* measure!
+
+* there are so many variables, you cannot care without benchmarks
 
 |pause|
 
-* just joking
+* if you have no benchmarks, you don't care
 
-Disclaimer
-----------
+This is not how I want to write software
+----------------------------------------
 
-* we're trying to make it better
+* I like my abstractions
+
+* I like Python
+
+* I don't want to rewrite stuff for performance
+
+|pause|
+
+* in C/C++
+
+Second best
+-----------
+
+* keep my abstractions
+
+* do arcane voodoo to keep my programs fast
+
+* but you have to understand the voodo in the first place
+
+But Python performance!
+-----------------------
+
+* there is no such thing as language performance
+
+* there is implementation performance
+
+* the language might be easier or harder to optimize
+
+* CPython performance characteristics is relatively straightforward
 
 What is PyPy?
 -------------
@@ -42,8 +97,6 @@
 
 * PyPy is a toolchain for creating dynamic language implementations
 
-  * we try to rename the latter to RPython
-
 * also, an Open Source project that has been around for a while
 
 Compilers vs interpreters
@@ -82,16 +135,20 @@
 
 * compiles loops and functions
 
+Some properties
+---------------
+
+* the code speed **changes** over time
+
+* hopefully from slow to fast
+
+* you need to warm up things before they get fast
+
 Some example
 ------------
 
 * integer addition!
 
-So wait, where are those allocations?
--------------------------------------
-
-* they don't escape, so they're removed!
-
 Abstractions
 ------------
 
@@ -103,8 +160,28 @@
 
 * if they don't introduce too much complexity
 
-Allocations
------------
+Few words about garbage collection
+----------------------------------
+
+* ``CPython``: refcounting + cyclic collector
+
+* ``PyPy``: generational mark & sweep
+
+|pause|
+
+* errr....
+
+The rest
+--------
+
+* I'll explain various PyPy strategies
+
+* ideally all this knowledge will be unnecessary
+
+* this is the second best, how to please the JIT compiler
+
+Allocations (PyPy)
+------------------
 
 * allocation is expensive
 
@@ -153,7 +230,18 @@
 
 * not all nicely
 
-Future improvements
--------------------
+Summary
+-------
 
-Xxxx
+* we hope this knowledge will not be needed
+
+* the more you care, the better you need to know
+
+Questions?
+----------
+
+* Thank you!
+
+* http://pypy.org
+
+* http://baroquesoftware.com


More information about the pypy-commit mailing list