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/index.rst
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,8 @@ The Hitchhiker's Guide to Python!
8
8
9
9
Welcome to The Hitchhiker's Guide to Python.
10
10
11
-
**This guide is currently under heavy active development.** If you'd like to help, `fork us on GitHub <https://github.com/kennethreitz/python-guide>`_!
11
+
**This guide is currently under heavy active development.** If you'd like to help,
12
+
`fork us on GitHub <https://github.com/kennethreitz/python-guide>`_!
12
13
13
14
This *opinionated* guide exists to provide both novice and expert Python
14
15
developers a best-practice handbook to the installation, configuration, and
Copy file name to clipboardExpand all lines: docs/scenarios/speed.rst
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ Using a slightly modified version of `David Beazleys`_ CPU bound test code
8
8
(added loop for multiple tests), you can see the difference between CPython
9
9
and PyPy's processing.
10
10
11
-
::
11
+
.. code-block:: console
12
12
13
-
PyPy
13
+
# PyPy
14
14
$ ./pypy -V
15
15
Python 2.7.1 (7773f8fc4223, Nov 18 2011, 18:47:10)
16
16
[PyPy 1.7.0 with GCC 4.4.3]
@@ -21,9 +21,9 @@ and PyPy's processing.
21
21
0.0440690517426
22
22
0.0695300102234
23
23
24
-
::
24
+
.. code-block:: console
25
25
26
-
CPython
26
+
# CPython
27
27
$ ./python -V
28
28
Python 2.7.1
29
29
$ ./python measure2.py
@@ -72,9 +72,10 @@ Cython
72
72
with which you are able to write C and C++ modules for Python. Cython also
73
73
allows you to call functions from compiled C libraries. Using Cython allows
74
74
you to take advantage of Python's strong typing of variables and operations.
75
-
Here is an example of strong typing with Cython:
76
75
77
-
.. code-block:: python
76
+
Here's an example of strong typing with Cython:
77
+
78
+
.. code-block:: cython
78
79
79
80
def primes(int kmax):
80
81
"""Calculation of prime numbers with additional
@@ -128,7 +129,7 @@ Notice that in the Cython version you declare integers and integer arrays for
128
129
to be compiled into C types while also creating a Python list:
129
130
130
131
131
-
.. code-block:: python
132
+
.. code-block:: cython
132
133
133
134
def primes(int kmax):
134
135
"""Calculation of prime numbers with additional
@@ -190,18 +191,22 @@ The `pyximport` module allows you to import `pyx` files (e.g., `primesCy.pyx`) w
190
191
The `pyximport.install()` command allows the Python interpreter to start the Cython compiler directly to generate C-code,
191
192
which is automatically compiled to a `*.so` C-library. Cython is able to import this library for you in your Python-code.
192
193
Very easy and very efficient. With the `time.time()` function you are able to compare the time between this 2 different calls to find 500 prime numbers.
194
+
On a standard notebook (dual core AMD E-450 1.6 GHz), the measured values are:
195
+
196
+
.. code-block:: console
197
+
198
+
Cython time: 0.0054 seconds
193
199
194
-
On a standard notebook (dualcore AMD E-450 1,6 GHz) the measured values are:
200
+
Python time: 0.0566 seconds
195
201
196
-
Cython time: 0.0054 seconds
197
202
198
-
Python time: 0.0566 seconds
199
203
200
204
And here the output of an embedded `ARM beaglebone <http://beagleboard.org/Products/BeagleBone>`_ machine:
0 commit comments