Skip to content

Commit 7ef55e7

Browse files
author
tommy3001
committed
minor changes (indentation fixed)
1 parent a30b491 commit 7ef55e7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/scenarios/speed.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ Strong typing with Cython:
124124

125125
.. code-block:: python
126126
127-
#primes function with additional Cython code:
128-
def primes(int kmax):
127+
#primes function with additional Cython code:
128+
def primes(int kmax):
129129
cdef int n, k, i
130130
cdef int p[1000]
131131
result = []
@@ -135,7 +135,7 @@ Normal variable definition in Python:
135135
.. code-block:: python
136136
137137
#primes in standard Python syntax:
138-
def primes( kmax):
138+
def primes( kmax):
139139
p= range(1000)
140140
result = []
141141
@@ -149,7 +149,8 @@ And what is with the speed? So lets try it!
149149
150150
import time
151151
#activate pyx compiler
152-
import pyximport; pyximport.install()
152+
import pyximport
153+
pyximport.install()
153154
#primes implemented with Cython
154155
import primesCy
155156
#primes implemented with Python
@@ -172,14 +173,15 @@ Where is the magic? Here it is:
172173

173174
.. code-block:: python
174175
175-
import pyximport; pyximport.install()
176+
import pyximport
177+
pyximport.install()
176178
177179
178180
With the module `pyximport` you are able to import Cython `*.pyx` files, in this case `primesCy.pyx`, with the Cython
179181
version of the primes function.
180182
The `pyximport.install()` command allows the Python interpreter to start the Cython compiler directly to generate C-code,
181183
which is automatically compiled to a `*.so` C-library. ... and Cython is able to import this library for you in your Python-code.
182-
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.
184+
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.
183185

184186
Here is the output of an embedded `ARM beaglebone <http://beagleboard.org/Products/BeagleBone>`_ machine:
185187

0 commit comments

Comments
 (0)