Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8f8054

Browse files
authored
Merge pull request #1096 from matheusfelipeog/feat/py2-to-py3-in-speed-section
Update examples to Python 3 in speed section
2 parents 6b5bc62 + 8d91ae9 commit e8f8054

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

docs/scenarios/speed.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,25 +168,23 @@ What's the difference in speed? Let's try it!
168168
.. code-block:: python
169169
170170
import time
171-
#activate pyx compiler
171+
# Activate pyx compiler
172172
import pyximport
173-
pyximport.install()
174-
#primes implemented with Cython
175-
import primesCy
176-
#primes implemented with Python
177-
import primes
178-
179-
print "Cython:"
180-
t1= time.time()
181-
print primesCy.primes(500)
182-
t2= time.time()
183-
print "Cython time: %s" %(t2-t1)
184-
print ""
185-
print "Python"
186-
t1= time.time()
187-
print primes.primes(500)
188-
t2= time.time()
189-
print "Python time: %s" %(t2-t1)
173+
pyximport.install()
174+
import primesCy # primes implemented with Cython
175+
import primes # primes implemented with Python
176+
177+
print("Cython:")
178+
t1 = time.time()
179+
print(primesCy.primes(500))
180+
t2 = time.time()
181+
print("Cython time: %s" % (t2 - t1))
182+
print("")
183+
print("Python")
184+
t1 = time.time()
185+
print(primes.primes(500))
186+
t2 = time.time()
187+
print("Python time: %s" % (t2 - t1))
190188
191189
192190
These lines both need a remark:

0 commit comments

Comments
 (0)