3 ms·
> So this is why every once in a while we see some article about Julia being as easy to use as Python while having nearly the performance of C. Here's a perfor
by ihnorton 9y ago
> So this is why every once in a while we see some article about Julia being as easy to use as Python while having nearly the performance of C.
Here's a performance testimonial with links to real code and benchmarks against Fortran (not Python), from Steven G. Johnson, one of the authors of FFTW:
https://discourse.julialang.org/t/julia-vs-fortran-complaint/4366/7 https://discourse.julialang.org/t/julia-vs-fortran-complaint...
I implemented an erfinv function Julia (https://github.com/JuliaLang/julia/pull/29874 https://github.com/JuliaLang/julia/pull/29874), and it was about 3x faster than Matlab or SciPy's erfinv function, both of which are taken from standard Fortran libraries. [...] I have found similar gains (compared to Fortran code called in SciPy) for other special functions, e.g. polygamma functions (https://github.com/JuliaLang/julia/pull/71255 https://github.com/JuliaLang/julia/pull/71255) and exponential integrals (https://github.com/JuliaMath/SpecialFunctions.jl/issues/19 https://github.com/JuliaMath/SpecialFunctions.jl/issues/19).
The reason Julia can beat the Fortran code is that metaprogramming makes it easy to apply performance optimizations that are awkward in Fortran. We have metaprogramming macros (@evalpoly) that can easily inline polynomial evaluations, whereas the Fortran code makes function calls that loop over look-up tables of polynomial coefficients. Even greater speedups are possible for evaluating polynomials of complex arguments, where there is a fancy recurrence from Knuth that is almost impossible to use effectively without code generation. In principle, the Fortran authors could have done the same inlining and gotten similar performance, but the code would have been much more painful to write by hand. (They could even have written a program to generate Fortran code, but that is even more painful.)
> I'd rather deal with Cython apache license than deal with this GPL stuff for commercial use.
The Julia core is MIT licensed. The language distribution is currently GPL licensed due to linked dependencies, but there has been a no-GPL build flag available for several releases. GPL (and other) dependencies are continually being removed, and there are only one or two (GPL) libraries left in the currently nightly build.