The Computer Language
25.01 Benchmarks Game

Python 3 versus PHP fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are * hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #2 464.80 16,339 447 463.62
PHP #4 130.83 19,780 1168 514.56
PHP #3 133.01 19,767 1166 525.32
PHP 592.64 16,400 488 591.45
Python 3 #6 943.88 11,874 391 942.63
Python 3 #4 311.18 28,701 960 1,221.85
PHP #8 1,733.62 16,335 477 1,732.08
Python 3 #8 2,457.09 11,874 414 2,455.59
n-body
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #3 204.10 16,425 1088 204.19—204.75
PHP #8 242.35 16,507 1245 242.61—244.24
Python 3 372.41 12,198 1201 371.23
Python 3 #2 442.06 12,554 1247 440.87
Python 3 #8 529.38 12,497 1172 528.16
spectral-norm
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP 18.29 24,682 1157 72.35—72.51
PHP #2 132.84 16,810 403 132.74—133.26
PHP #8 135.79 16,601 357 136.40—136.76
PHP #3 35.62 26,657 1214 141.28—141.39
Python 3 #6 349.68 13,660 334 348.48
Python 3 #4 90.37 34,693 415 352.91
Python 3 #8 386.45 12,833 334 385.07
Python 3 #7 109.91 34,578 425 421.84
mandelbrot
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP 258.19 16,437 452 258.37—264.30
PHP #3 68.29 53,531 881 273.76—275.55
PHP #8 424.00 49,336 419 422.73
Python 3 #7 182.94 62,173 698 723.28
Python 3 #3 879.41 45,085 319 877.96
Python 3 #2 237.64 230,973 790 937.87
Python 3 #5 260.63 61,620 463 1,033.16
Python 3 #8 1,577.29 45,031 379 1,575.80
fasta
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #3 31.10 16,433 1065 31.08—31.16
Python 3 #3 39.03 12,218 1007 38.87—47.23
Python 3 #2 39.06 12,415 1126 39.10—46.32
PHP #2 47.59 16,388 1054 47.61—47.79
PHP #8 49.83 16,388 760 49.86—49.95
Python 3 #5 27.95 1,190,347 1951 54.25—54.92
Python 3 57.39 12,100 823 57.48—65.23
Python 3 #8 153.17 11,915 738 154.06—158.15
k-nucleotide
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #8 79.70 649,593 571 80.08—80.46
PHP #4 25.77 270,369 1290 89.42—89.86
Python 3 #3 46.55 674,185 1970 182.63—187.07
Python 3 #4 76.67 523,751 663 233.38—238.93
Python 3 #8 234.08 642,265 525 235.45—236.80
Python 3 234.20 515,047 499 235.22—237.04
Python 3 #9 66.67 392,184 614 236.55—238.32
reverse-complement
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
Python 3 #3 4.96 523,801 803 4.95
Python 3 #5 4.18 2,418,156 960 7.46—7.50
Python 3 #2 10.09 1,837,285 440 10.14—10.23
PHP 10.35 1,531,154 323 10.35
Python 3 10.43 2,040,713 484 10.44—10.58
Python 3 #6 7.59 2,795,930 821 11.07—11.11
PHP #2 12.31 1,836,716 288 12.31—12.35
PHP #3 8.29 1,821,659 452 12.59
Python 3 #4 13.47 4,109,324 343 13.47—13.85
binary-trees
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #3 69.00 948,552 434 69.06—69.22
PHP #7 22.24 1,316,532 767 81.52—81.90
PHP #4 24.74 1,280,827 786 81.33—81.59
PHP 90.45 771,105 457 90.70—90.97
PHP #2 93.90 771,146 429 93.90—94.38
Python 3 #2 100.49 281,829 344 100.71—101.07
Python 3 #4 33.37 460,771 481 121.34—121.66
Python 3 34.85 445,649 597 123.14—123.93
PHP #5 47.09 1,745,932 1048 124.25—125.29
Python 3 #5 35.37 806,117 669 125.73—126.09
PHP #6 38.32 2,379,801 877 130.50—131.11
PHP #8 146.65 773,100 590 146.78—147.89
Python 3 #3 51.88 819,077 1247 148.97—149.82
Python 3 #8 560.84 821,846 535 559.59
pidigits
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
PHP #5 1.01 17,302 405 1.00
PHP #4 1.02 17,355 396 1.01
PHP #3 1.03 17,367 510 1.02
* Python 3 #3 1.35 20,009 573 1.28—1.32
PHP #2 1.51 17,756 552 1.50
Python 3 #4 4.63 12,718 348 4.60
PHP 102.79 18,395 756 102.77—102.80
Python 3 #5   Empty  
regex-redux
  elapsed     Mean or 95% CI
source secs mem gz cpu secs
* Python 3 #2 1.41 191,300 1411 2.65
PHP 1.88 203,751 822 3.67
Python 3 8.96 459,624 515 16.49—16.73
Python 3

Python 3.13.0

PHP

PHP 8.4.1 (cli)
(built: Nov 22 2024 14:22:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.1,
with Zend OPcache v8.4.1,
Copyright (c) Zend Technologies