News for hackers. Stuff that matters.
Re:Why Is Python So Popular in 2025? – The PyCharm Blog by zahlman on Wednesday October 01, 2025 @05:32PM (#45443813)
>But if I ask Python to [add up about a hundred million] [32-bit floating point numbers in the naive way], Python takes about twenty seconds anyway

Really?

  $ python -m timeit -s 'import random; x = [random.random() for _ in range(100000000)]' 'sum(x)'
  1 loop, best of 5: 806 msec per loop
This is on 11-year-old hardware. Even the generation isn't that slow:

  $ time python -c 'import random; x = [random.random() for _ in range(100000000)]'

  real    0m10.942s
  user    0m9.590s
  sys     0m1.346s
Of course, Python forces the use of doubles internally. Any optimizations inherent to 32-bit floats are simply not available.

There are no comments on this comment yet.