5 ms·
So... 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
by tomp 5y ago
So... 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…