Home > Mobile >  why is Python faster than Nodejs in my computer
why is Python faster than Nodejs in my computer

Time:09-26

I've made a program in both Nodejs and Python that prints the output of some complex calculs in a function

Nodejs:

function calc(num) {
    return Math.pow(num, Math.random()) - (num   5) / 8
}

for(let i = 0;i < 1000;i  ) {
    console.log(calc(8))
}

// it took 2:63s in Nodejs

Python:

import random
def calc(num): 
    return num ** random.random() - (num   5) / 8

for i in range(1000):
    print(calc(8))

it took 2:27s in python

am a JS dev not a python expert

CodePudding user response:

As per this blog https://neoteric.eu/blog/node-js-vs-python/

As Node.js is based on fast and powerful Chrome’s V8 engine, Node.js is faster than Python, and generally one of the fastest server-side solutions around. Sure, there are technologies that are faster… in certain situations.

  • Related