Cell list algorithm is slower than double for loop

That’s fine. The topic is a bit complicated, I needed some time to grasp the concept.

Parametric types define structures whose fields can have multiple types, but those types must be declared before use. Vector{Int} is an example, with the type parameter Int.
The above struct may be written as

struct PointsCells{P,C,S}
    points::P
    cell::C
    pairs::S
end

That makes it easier to play with various representations. Say, the points may be in a vector of tuples instead of a matrix, Pairs instead of 2-tuples may be used for pairs, while the structure definition won’t need any change if it’s parametric. I now often find myself writing a parametric type even when I don’t plan using multiple data representations, only because the concrete type names are too long.

Omitting field types hits performance, as the types then become non-inferrable at compile time, so it’s generally not recommended. But then again, you may do it to play with different representations and put concrete types once you’ve made the decision which one best suits your needs.

The manual entry on parametric types: Types · The Julia Language
I’d also recommend the book discussed in topic New book: Hands-on Design Patterns and Best Practices with Julia

1 Like