|
back to index libmpdec cdecimal Python module decimal benchmarks multi precision benchmarks Python/Java benchmarks |
This benchmark compares the Python modules cdecimal.so, decimal.py and Java's BigDecimal class. Python's native binary float type and gmpy's binary mpf type are included for a better overview.
The benchmark runs 10000 iterations of calculating pi to various precisions.
| Python native | cdecimal | gmpy | decimal.py | Java BigDecimal | |
| 9 digits | 0.116s | 0.239s | 0.458s | 19.44s | 0.526s |
| 19 digits | - | 0.514s | 0.457s | 45.74s | 1.454s |
| 38 digits | - | 1.124s | 0.946s | - | 5.678s |
| 100 digits | - | 3.855s | 3.039s | - | 45.453s |
| Python native | cdecimal | gmpy | decimal.py | Java BigDecimal | |
| 9 digits | 0.447s | 2.921s | 4.607s | 104.49s | 2.83s |
| 19 digits | - | 6.440s | 4.591s | 246.67s | 15.14s |
| 38 digits | - | 15.449s | 9.588s | - | 59.87s |
| 100 digits | - | 44.980s | 27.224s | - | 464.71s |
This benchmark compares the Python modules cdecimal.so and gmpy. Python's native integer type is included for a better overview.
The benchmark calculates the factorial of huge numbers. The timings are split into pure calculation time and conversion time to decimal string.
The factorial algorithm is chosen for comparison purposes. Faster algorithms are described here: Fast Factorial Functions
| Python native | cdecimal | gmpy | |
| 100000! | 1.60s + 71.94s | 0.44s + 0.01s | 0.21s + 0.18s |
| 1000000! | 76.24s + >2h | 7.62s + 0.07s | 3.15s + 6.51s |
| 10000000! | - | 94.60s + 0.85s | 50.07s + 165.67s |
| Python native | cdecimal | gmpy | |
| 100000! | 7.10s + 250.37s | 4.68s + 0.02s | 1.55s + 0.991s |
| 1000000! | - | 71.24s + 0.31s | segfault |
| 10000000! | - | 896.61s + 3.71s | - |