how make a simple cpython program from scratch and measure it performance gain with its respective python program.. example if I make a program of 10! in python and the in Cpython how would I know how much it improves the performance of computation.
Asked
Active
Viewed 23 times
0
-
1python is cpython ... Do you mean cython? – MegaIng Apr 19 '18 at 13:20
1 Answers
0
Take a look at : How to use timeit module
simple code to test time taken for a function:
def time_taken(func):
from time import time
start = time()
func()
end = time()
return (end - start)
def your_func():
#your code or logic
# To test
time_taken(your_func)
Use this mechanism to test time taken in both situations.
Let's say CPython took c seconds & Python took p seconds, CPython is faster than Python by: (c - p) * 100 / p
If c is 2 secs & p is 1 sec. CPython is faster than Python by (2-1)*100/1 = 100%
However, the performance keeps changing depending on the code & problem statement.
Share the output. Goodluck!

Sahith Vibudhi
- 4,935
- 2
- 32
- 34