Any suggestions for speeding this simple scalar function up?

You sure?

julia> @btime ρ0 ^ γ setup = (ρ0 = 1000.0; γ = 7)
  85.486 ns (0 allocations: 0 bytes)
1.0e21

julia> @btime ρ0 ^ γ setup = (ρ0 = 1000.0; γ = 7.0)
  85.442 ns (0 allocations: 0 bytes)
1.0e21

Maybe that’s true when the exponent is a literal, or a small (< 4) integer, but if you’re using a variable that is larger than 3, the exponent is converted to a float anyway

Ehr…

2 Likes