Message105607
Here is one more datapoint.
$ ./python.exe -m timeit -s "import factorial4 as fm;
fm.partial_product = fm.partial_product; f = fm.factorial " "f(10000)"
10 loops, best of 3: 66.1 msec per loop
[32794 refs]
$ ./python.exe -m timeit -s "import factorial4 as fm;
fm.partial_product = fm.partial_product3; f = fm.factorial "
"f(10000)"
10 loops, best of 3: 63 msec per loop
[32794 refs]
$ ./python.exe -m timeit -s "import factorial4 as fm;
fm.partial_product = fm.partial_product2; f = fm.factorial "
"f(10000)"
10 loops, best of 3: 43.3 msec per loop
partial_product3 multiplies adjacent numbers instead of first by last.
I am not sure it reproduces the order of multiplication in the
recursive version exactly, but it does show that the order of
multiplication matters a lot.
I wonder if one could write an elegant recursive version that would
multiply first by last in partial_product. |
|
Date |
User |
Action |
Args |
2010-05-12 20:34:33 | belopolsky | set | recipients:
+ belopolsky, rhettinger, mark.dickinson, draghuram, stutzbach |
2010-05-12 20:34:31 | belopolsky | link | issue8692 messages |
2010-05-12 20:34:31 | belopolsky | create | |
|