[Tin tức] Python vs JavaScript – side by side comparison



Python vs JavaScript test of the relative performance.
As an example I took basic prime-finding algorithm with N² complexity.

All found primes are stored in a list/array and as the result scripts print the length of the list/array.
I tested a relative speed of code writing, including typos.
And the Python and JavaScript performance.

Python vs JavaScript – side by side comparison

FOLLOW ME:
Telegram:
Twitter:
Facebook:

MY COURSES:

or

#python #javascript #redeyedcoderclub

26 bình luận về “[Tin tức] Python vs JavaScript – side by side comparison”

  1. Yeap, CPython have no JIT (in this version), so… But if you compare Py and JS in more real world scenario with db and async network things – you can't see much difference. Mostly JS faster. But sometimes Py can be faster bc of the best integration with C.
    Btw, if you need speed – you use Numpy or PyPy/numba/pypyc or Cython. Or even Java, Go, Rust, C, Fortran, etc 😀

    Bình luận
  2. This is just because Python integers are boundless integers (like BigInteger in Java), while JavaScript numbers are fixed-size floating point numbers. This is the same reason Python 3 is usually slower than Python 2 (which used fixed-size integers when possible).

    Bình luận
  3. Hi. Very dumb programming question probably but how does the function deal with the different return values of the different blocks inside of it (for and if blocks)? If if the if block returns “false”, the for block returns “true” anyway or did I misunderstood something? Thanks.

    Bình luận
  4. that programming part was like… eh… I'd say made by somene who just wanted python to win… you could write JS version like this:
    for (let i = 2; i < n; i++) if (n % i == 0) return false; return true;
    or even
    for (let i = 2; i < n; i++) if (!(n % i)) return 0; return 1;
    it might not look so good, but it's way to make code shorter

    Bình luận
  5. Was super excited when first clicked because I thought this would finally show me how to swap each Python syntax to become Javascript syntax. However… OpenAI Codex is somewhat helping me build such an app, held back because the input allowance is far too limited whereas shortening the script keeps breaking it far too much.

    Bình luận

Viết một bình luận

bahis10bets.com betvole1.com casinomaxi-giris.com interbahis-giris1.com klasbahis1.com mobilbahisguncelgiris1.com piabetgiris1.com tipobettgiris.com tumbetgiris1.com betboro 1xbet giriş
bahis10bets.com betvole1.com casinomaxi-giris.com interbahis-giris1.com klasbahis1.com mobilbahisguncelgiris1.com piabetgiris1.com tipobettgiris.com tumbetgiris1.com betboro 1xbet giriş
antalya bayan escort
antalya bayan escort
antalya bayan escort