

Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- you should include a faster version of the fibonacci function with exponentiation by squaring
see https://oeis.org/wiki/User:Natalia_L._Skirrow/linear_recurre... (warning: old and bad and in need of revision), https://github.com/sympy/sympy/pull/30452 and https://github.com/sympy/sympy/pull/30541 for details of how to make similarly fast programs for arbitrary linear-recurrent sequences.def fibonacci(k): a,b=(0,1) for i in range(k.bit_length()-1,-1,-1): d=a**2 c=2*a*b-d d+=b**2 (a,b)=(d,c+d) if k>>i&1 else (c,d) return ayou can also encode polynomials into integers; see https://mathstodon.xyz/@peterluschny/116320199782572958 and the following prog from https://codegolf.stackexchange.com/a/279771
both of these would be more intensive on the arithmetic side rather than control flowlambda n:pow(p:=2<<n,n,p*p+~p)//palso you could at least wrap the existing one in a `functools.cache`
by DroneBetter - My pet peeve are numbers with too many decimals. If you only run a benchmark three times and take the arithmetic mean you don't have five or more significant digits. At best, you have two. And for benchmarking the geometric mean is a far superior mean.by bjourne
- Answer: not fast at all.by dezsiszabi
- This doesn't seem to test the GC, nor important operations such as dict lookup/iteration, set add/membership, list iteration and updating.
Is really a recursive implementation of Fib an enlightening benchmark? I don't think so. And bubblesort is just messing around with two pointers.
Why not, if you're first doing benchmarking, find out what the most time consuming popular operations/algorithms are, and then use them?
Now it seems that you are just testing two obscure algorithms that are not really representative for Python coding in general.
by JohnKemeny - So Claude can convert python code bases to rust or golang, and give you an easy 10x speed boost. Much better than waiting for Python performance to improveby brianwawok
- only tangentially related, but naming PyPy when PyPI was already established was ridiculousby scosman
- 35 years on since the first public Python release and there's still so much room for improvement in its performance. These tests by Miguel are a useful quick check on that progress in 3.15 even if as he admits it's impossible to get "an objective and universal measure of the performance of a programming language".by makaimc
- So not much progress since 3.14 - but still progress! Personally, I think it's nice when my code automatically gets faster thanks to someone else's work, and I don't understand all the negative sentiment in this thread. Yes, of course Python is still a slow language. You hopefully knew that when you picked Python for your project.by jakobnissen