Author: Maciej Fijalkowski <[email protected]>
Branch: extradoc
Changeset: r4076:2368ff076bfd
Date: 2012-02-04 22:21 +0200
http://bitbucket.org/pypy/extradoc/changeset/2368ff076bfd/
Log: start writing examples
diff --git a/talk/pycon2012/tutorial/examples/01_refcount.py
b/talk/pycon2012/tutorial/examples/01_refcount.py
new file mode 100644
--- /dev/null
+++ b/talk/pycon2012/tutorial/examples/01_refcount.py
@@ -0,0 +1,9 @@
+
+def wrong():
+ open("file").write("data")
+ assert open("file").read() == "data"
+
+def right():
+ with open("file") as f:
+ f.write("data")
+ # contents *will be there* by now
diff --git a/talk/pycon2012/tutorial/examples/02_speedup.py
b/talk/pycon2012/tutorial/examples/02_speedup.py
new file mode 100644
--- /dev/null
+++ b/talk/pycon2012/tutorial/examples/02_speedup.py
@@ -0,0 +1,11 @@
+
+def f():
+ s = 0
+ for i in xrange(100000000):
+ s += 1
+ return s
+
+if __name__ == '__main__':
+ import dis
+ dis.dis(f)
+ f()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit