Who would've thought that V8 that gets millions invested in it by a huge company would outperform community made Python.
I'd be hard pressed to find any mainstream language that underperforms naïve CPython. Community driven or not.
Node.js 14 is over 20x faster than Python3.8 for fib(n)
71–80 of 119 posts
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#72Ignoring the bad implementation of fib(n) and use of a Python interpreter without JIT... why does this matter? Python and JavaScript are scripting languages. Their advantages are being highly portable and relatively easy to develop and maintain. Performance has always been a weakness of both languages when compared to their pre-compiled siblings. That limitation is often mitigated by "gluing" together functionality i…
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#73Doesn't the Node.js version use double precision floating point vs python using infinite precision integers ? That would explain part of the difference in performance, and make the python version exact, but js version inexact.
JS with number 138 ms (x1)
JS with BigInt (eg. 35n) 2620 ms (x19)
Python 3260 ms (x24)Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#74An interpreter with a JIT is obviously faster than one without. Especially when dealing with CPU bound work. I'm not sure this is entirely noteworthy unless you somehow think CPython has a JIT. Would be much more interesting to compare to pypy.
> An interpreter with a JIT is obviously faster than one without. And why doesn't python's default runtime environment obviously come with a JIT then? I think they should absolutely go for it, given the huge user base of python. Reasons like "but named functions can dynamically change" are not applicable, since JS has those same properties and can do it. They could start with optimizing the case where you call the sa…
Python lets you do _far_ more shenanigans that Javascript does; and a lot of large libraries depend on some of that behavior. Breaking it would probably cause a new 2 -> 3 situation.
https://www.youtube.com/watch?v=qCGofLIzX6g&feature=emb_titl...
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#75Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#76Earlier quoted context omitted.
Numba (asked by a commenter that haas since deleted: 638.8082504272461 ms
I asked, run it twice. The first time is for compilation. The second time it reaches 90ms on my machine.
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#77Earlier quoted context omitted.
Seems like an unduly harsh take. Is everyone just supposed to inherently know this fact about cpython or find it unsurprising when they run across it? "Obviously this isn't the most comprehensive benchmark, but the results are surprising to me." I fully agree with this and I learned something new about cpython's weakpoints today!
If I’m writing an article about benchmarking, then yes.
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#78Python isnt made for performance, but for good code readability. Write clear, logical code for small and large-scale projects. It is also made by Guido to build applications in less time. Guido knows his language isnt the fastest, but thas wasnt the goal with Python.
Node.js is also made for other applications than Python. It's great for web developers to be in the "JavaScript everywhere" world. So it is easy for web developers to write backend and frontend code with the "same" language. It's also great for event's and "real time" communication with the (web) application.
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#791. Python doesn't have a JIT. This shouldn't be surprising or headline worthy. 2. Why benchmark an O(2^n) fibonacci? It's basically benchmarking call frame creation. 3. A single order of magnitude is honestly not that impressive a speedup for JIT vs. no JIT. Might have a lot to do with the inefficiency of the recursive fibonacci func. Also, to quote another poster: @numba.njit def fib(n): if n == 1 or n == 0: return…
You'd have to also run the node version on your machine to know, as it's unlikely you have the exact same setup as TFA.
Re: Node.js 14 is over 20x faster than Python3.8 for fib(n)
#80I've seen these types of comparisons, and I understand there a loads of factors playing a part in them. However, it does make me wonder, why has python become to standard for data science? Is it Library support or purely community based?
It's because to a reasonably approximation of "None" - none of the actual data science runs in Python, it's all hyper customized libraries which do run (close to) metal fast once the data has been loaded into the appropriate data structures. Pandas is a shim on top of Numpy, which heavily leverages the Fortran77 BLAS/LAPACK libraries. Python is used at the top of the stack because it's an easy language to learn, you…
Also interactivity and quick feedback cycle, stuff like Jupyter Notebooks (né IPython Notebooks, a spinoff from the IPython project), matplotlib, ...