Getting the last element of an iterator

  1. sum documentation does not give a complexity guarantee. It is a different thing to defend the documentation of Base.last to not have O(1) as a requirement, and defend that this requirement is to be ignored before Julia 2.0, in which it can be changed.
  2. The expected complexity of sum is O(n-1 Base.+ operations for the eltype) where n is the number of elements in the container. sum(diagonal_mat) and sum(ordinary_dense_matrice) both follow such complexity. What is N in your example? The length of one dimension of the container? This does not seem standard.

I don’t see why last should not simply be expected to ‘return the last element of an iterator’, complexity be damned.

Well, I already give why I think so in this thread, and you are not addressing it. So I believe this is rhetorical.