News for hackers. Stuff that matters.
Re:Type Stability in Julia: Avoiding Performance Pathologies... by kwertzzz on Thursday December 09, 2021 @04:08AM (#29495316)
The code_warntype macro is helpful, but to prevent a future inadvertently introduced type stability, a failing test would be much better.

Test.@inferred is not quite what is needed:

    function foo(x)
      s = 0 
      # better use a zero of the same type than x
      # s = zero(x)
      for y in x
        s += y
      end
      return s
    end

    Test.@inferred Float64 foo(12.1) 
This test succeeds even if code is type-unstable

There are no comments on this comment yet.