The Computer Language
24.04 Benchmarks Game

PHP versus Python 3 fastest performance

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
source secs mem gz cpu secs
PHP #2 188.01 19,392 447 188.00
PHP #3 54.65 19,392 1166 217.72
PHP #4 55.26 19,520 1168 219.72
PHP 225.18 19,392 488 225.17
Python 3 #6 1,031.38 19,652 391 1,031.34
Python 3 #4 300.68 19,652 960 1,189.39
n-body
source secs mem gz cpu secs
PHP #3 66.45 19,396 1088 66.43
Python 3 #2 362.72 19,656 1247 362.70
Python 3 368.32 19,656 1201 368.30
spectral-norm
source secs mem gz cpu secs
PHP 6.85 19,396 1157 27.12
PHP #2 56.73 19,396 403 56.73
PHP #3 16.19 19,396 1214 63.39
Python 3 #7 90.77 19,656 425 359.32
Python 3 #6 359.89 19,656 334 359.83
Python 3 #8 98.97 19,656 415 386.79
mandelbrot
source secs mem gz cpu secs
PHP 86.84 19,396 452 86.84
PHP #3 23.33 48,384 881 92.86
Python 3 #7 159.49 19,656 698 634.00
Python 3 #3 820.95 19,624 319 820.91
Python 3 #2 232.82 156,340 790 880.90
Python 3 #5 274.66 19,628 463 1,094.30
pidigits
source secs mem gz cpu secs
PHP #5 1.02 19,396 405 1.02
PHP #4 1.04 19,396 396 1.04
PHP #3 1.05 19,396 510 1.04
Python 3 #3 1.31 19,784 573 1.31
PHP #2 1.47 19,396 552 1.46
Python 3 #4 4.73 19,656 348 4.73
PHP 330.35 19,396 756 330.33
Python 3 #5   Failed  
regex-redux
source secs mem gz cpu secs
Python 3 #2 1.35 168,092 1411 2.62
PHP 1.87 194,876 822 3.72
Python 3 8.83 432,724 515 16.44
fasta
source secs mem gz cpu secs
PHP #3 21.34 19,396 1065 21.33
PHP #2 28.90 19,396 1054 28.90
Python 3 #2 38.53 19,652 1126 38.53
Python 3 #3 38.86 19,780 1007 38.86
Python 3 #5 26.54 827,148 1951 53.26
Python 3 60.37 19,652 823 60.37
k-nucleotide
source secs mem gz cpu secs
PHP #4 20.89 260,560 1084 69.85
Python 3 #3 48.64 262,016 1970 184.81
Python 3 #8 87.79 506,880 663 262.44
Python 3 #9 77.06 380,416 614 263.65
Python 3 275.64 500,224 499 274.74
reverse-complement
source secs mem gz cpu secs
Python 3 #3 5.18 509,108 803 5.18
Python 3 #5 4.07 1,500,240 960 7.41
PHP 9.76 1,489,428 323 9.76
Python 3 #2 10.46 1,788,876 440 10.46
Python 3 10.69 1,987,304 484 10.69
Python 3 #6 7.86 2,484,084 821 11.49
PHP #2 11.67 1,787,276 288 11.67
PHP #3 7.59 536,536 452 11.93
Python 3 #4 13.91 4,003,712 343 13.91
binary-trees
source secs mem gz cpu secs
PHP #3 45.78 921,600 434 45.78
PHP #7 15.25 948,480 767 54.73
PHP #4 18.02 918,400 786 55.68
PHP 62.31 748,808 457 62.30
PHP #2 62.55 748,812 429 62.54
PHP #5 32.58 805,504 1048 83.64
PHP #6 26.90 805,396 877 88.00
Python 3 #2 110.47 273,024 344 110.46
Python 3 #4 34.53 277,632 481 126.59
Python 3 #5 35.74 275,456 669 127.53
Python 3 36.16 277,760 597 128.12
Python 3 #3 55.05 672,384 1247 158.56
PHP

PHP 8.3.3 (cli)
(built: Mar 3 2024 08:47:21) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.3,
with Zend OPcache v8.3.3,
Copyright (c) Zend Technologies

Python 3

Python 3.12.2