You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/scenarios/speed.rst
+40-4Lines changed: 40 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,32 @@ Speed
3
3
4
4
CPython, the most commonly used implementation of Python, is slow for CPU bound tasks. `PyPy`_ is fast.
5
5
6
-
.. todo:: Fill in stub for Speed comparisons
6
+
Using a slightly modified version of `David Beazleys`_ CPU bound test code(added loop for multiple tests), you can see the difference between CPython and PyPy's processing.
7
+
8
+
::
9
+
10
+
PyPy
11
+
$ ./pypy -V
12
+
Python 2.7.1 (7773f8fc4223, Nov 18 2011, 18:47:10)
13
+
[PyPy 1.7.0 with GCC 4.4.3]
14
+
$ ./pypy measure2.py
15
+
0.0683999061584
16
+
0.0483210086823
17
+
0.0388588905334
18
+
0.0440690517426
19
+
0.0695300102234
20
+
21
+
::
22
+
23
+
CPython
24
+
$ ./python -V
25
+
Python 2.7.1
26
+
$ ./python measure2.py
27
+
1.06774401665
28
+
1.45412397385
29
+
1.51485204697
30
+
1.54693889618
31
+
1.60109114647
7
32
8
33
Context
9
34
:::::::
@@ -12,7 +37,13 @@ Context
12
37
The GIL
13
38
-------
14
39
40
+
`The GIL`_ (Global Interpreter Lock) is how Python allows multiple threads to operate at the same time. Python's
41
+
memory management isn't entirely thread-safe, so the GIL is requried to prevents multiple threads from running
42
+
the same Python code at once.
15
43
44
+
David Beazley has a great `guide`_ on how the GIL operates. He also covers the `new GIL`_ in Python 3.2. His
45
+
results show that maximizing performance in a Python application requires a strong understanding of the GIL,
46
+
how it affects your specific application, how many cores you have, and where your application bottlenecks are.
16
47
17
48
C Extentions
18
49
------------
@@ -21,8 +52,8 @@ C Extentions
21
52
The GIL
22
53
-------
23
54
24
-
25
-
55
+
`Special care`_ must be taken when writing C extensions to make sure you register your threads
0 commit comments