mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 06:46:17 +00:00
Merge pull request #1096 from matheusfelipeog/feat/py2-to-py3-in-speed-section
Update examples to Python 3 in speed section
This commit is contained in:
+14
-16
@@ -168,25 +168,23 @@ What's the difference in speed? Let's try it!
|
||||
.. code-block:: python
|
||||
|
||||
import time
|
||||
#activate pyx compiler
|
||||
# Activate pyx compiler
|
||||
import pyximport
|
||||
pyximport.install()
|
||||
#primes implemented with Cython
|
||||
import primesCy
|
||||
#primes implemented with Python
|
||||
import primes
|
||||
import primesCy # primes implemented with Cython
|
||||
import primes # primes implemented with Python
|
||||
|
||||
print "Cython:"
|
||||
t1= time.time()
|
||||
print primesCy.primes(500)
|
||||
t2= time.time()
|
||||
print "Cython time: %s" %(t2-t1)
|
||||
print ""
|
||||
print "Python"
|
||||
t1= time.time()
|
||||
print primes.primes(500)
|
||||
t2= time.time()
|
||||
print "Python time: %s" %(t2-t1)
|
||||
print("Cython:")
|
||||
t1 = time.time()
|
||||
print(primesCy.primes(500))
|
||||
t2 = time.time()
|
||||
print("Cython time: %s" % (t2 - t1))
|
||||
print("")
|
||||
print("Python")
|
||||
t1 = time.time()
|
||||
print(primes.primes(500))
|
||||
t2 = time.time()
|
||||
print("Python time: %s" % (t2 - t1))
|
||||
|
||||
|
||||
These lines both need a remark:
|
||||
|
||||
Reference in New Issue
Block a user