6 ms·
Julia vs. Python 3 – Which programs are fastest?
- tomp 5y agoSo... I checked the nbodies code. Python: simple, short, very obvious what's going on, completely unoptimized. I wonder how much faster it would be, if it was (1) vectorized with numpy, and then (2) numba on top. I doubt it would be much less readable. Julia: highly optimized (many "inline" annotations etc.), vectorized, much less readable than Python. TL;DR: this isn't a fair comparison.
- martopix 5y agoI've seen lots of comparisons between Julia and Python, since the Julia community love those. So far I've seen zero using numpy.
- smitty1e 5y agoOK, so Julia beats stock Python for some benchmarks. There is no shame in offering credit where due.
- igouy 5y agoDoes the "numpy community" provide those?
- adgjlsfhk1 5y agogenerally numpy closes the gap to within 2x as long as all your operations are easily vectorizable, and none of your arrays have a size less than 100 or so. for small arrays, numpy is around 1000x slower than Julia because every operation has a large overhead (somewhere in the range of 10 us)
- detaro 5y agoThe slower Julia variants don't seem less readable than the Python one to me and still are a lot faster.
- mardiyah 5y agoThat's the truth, the fact
- igouy 5y agoMore than one Python program, more than one Julia program: > many "inline" annotations etc. https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-julia-2.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- DNF2 5y agoI'd say most of those optimizations are not needed (`@inline`, `@ntuple`, `@inbounds` can also often be dropped). Vectorization, in the sense of using `.+` etc, does not provide any speedup in Julia, it is only for notational convenience, and is at best the same speed as a loop, often slower.
- igouy 5y ago> I'd say… People do say, but without program measurements…
- deepsun 5y agoLooks like in regards to RAM, Julia is the new Java -- doesn't care for 5x larger RAM consumption. (I actually like it, RAM is cheap nowadays).
- igouy 5y agohttps://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071 https://discourse.julialang.org/t/why-does-julia-have-around...
- ChrisRackauckas 5y agoJulia v1.8 will have a pretty big change in terms of the runtime, in that the runtime will no longer necessarily need to have LLVM attached to it: https://github.com/JuliaLang/julia/pull/41936 https://github.com/JuliaLang/julia/pull/41936
- DNF2 5y agoIsn't this mainly because the first run includes compilation? The compiled code should use little memory, if correctly written.
- ChrisRackauckas 5y agoYes, most of it is the compilation.
- dunefox 5y agoI agree, more RAM for much more speed is an acceptable tradeoff.
- rich_sasha 5y agoJulia also sets an env var JULIA_NUM_THREADS to 4. I’m just guessing what that means... the Python code is painfully unoptimised, the Julia one has plenty of inclining, uses native vector types vs naked lists etc. I feel like Julia, faster though it seems to be, has a massive chip on the shoulder, keeps proving its erm performance is bigger than everyone else. On the benchmarks where Julia is faster, it’s time is in bold. On the one regex one where Python happens to be faster, no bold. I guess outliers can be gleaned over.
- igouy 5y ago> … the Python code is painfully unoptimised… It's not numpy. It's not numba. … https://pybenchmarks.org/ https://pybenchmarks.org/ > in bold A versus B, bold shows when the fastest A program is faster.
- DNF2 5y agoThe Benchmarks Game isn't some Julia project, and it is unreasonable to blame the presentation of results on some 'chip on the shoulder' of Julia the language. The Benchmarks Game is a project that dates back to at least 2002 (https://benchmarksgame-team.pages.debian.net/benchmarksgame/sometimes-people-just-make-up-stuff.html#history https://benchmarksgame-team.pages.debian.net/benchmarksgame/...), a decade before Julia was announced, collects code from many different languages, and lets you filter the results depending on what you are interested in. Go to the website, click on Python, and when selecting the other language, Python's results are in bold. Why should Julia users be criticized for contributing code to a website dedicated to performance benchmarks, but it's ok for Python/Fortran/C/Javascript users to contribute? And why should this contribution from some individual count as evidence of some 'shoulder chip' for the wider language community? (BTW, all benchmarks in all languages appear to be running on 4 cores, so it's not that weird for Julia to set NUM_THREADS to 4.)
- snicker7 5y agoI don’t see the point of this post. Julia is a compiled language, Python is interpreted. Comparing them on CPU-intensive algos is unfair.
- igouy 5y agoNot "unfair". We get to see how they compare.