Strange outcome for the Julia list with different type of elements

Basically, homogeneous containers (analogous to numpy arrays) are much faster than heterogeneous containers, so Julia usually prefers to promote to a common type if possible (it’s not possible if one element is a scalar and another is a vector).

But of course you can opt out if you specifically want Vector{Any} (the analogue of a Python list).

6 Likes