# Container type declaration when computing equivalence classes for performance vs genericity

**URL:** <https://discourse.julialang.org/t/container-type-declaration-when-computing-equivalence-classes-for-performance-vs-genericity/64353>\
**Category:** New to Julia\
**Tags:** performance\
**Created:** [July 9, 2021, 1:48pm UTC](https://discourse.julialang.org/t/container-type-declaration-when-computing-equivalence-classes-for-performance-vs-genericity/64353 "2021-07-09T13:48:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Post date:** [July 9, 2021, 1:48pm UTC](https://discourse.julialang.org/t/container-type-declaration-when-computing-equivalence-classes-for-performance-vs-genericity/64353/1 "2021-07-09T13:48:39Z")

</div>

It is advised in the performance section of the documentation that container type should not be AbstractType for better performance. I wonder what is the correct way to declare container `partition, data` in the following pseudocode and if these proper declaration will boost my performance. Note that I do know and control the output type of `computeEquivalenceClass, computeAdditionalDatum`.

```julia
baseSet = collect(1:10e10)
partition = [] # Array{Any}
data = [] # Array{Any}
while !isempty(baseSet)
    class = computeEquivalenceClass()
    datum = computeAdditionalDatum()
    push!(partition, class)
    push!(data, datum)
    filter!(k->!(k in class), baseSet)
end

```

Thank you.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [July 9, 2021, 2:30pm UTC](https://discourse.julialang.org/t/container-type-declaration-when-computing-equivalence-classes-for-performance-vs-genericity/64353/2 "2021-07-09T14:30:30Z")

</div>

If, for example, `class` is of type `MyClass` initialize `partition` with:

```julia
partition = MyClass[]

```

or, if you feel to be more explicit,

```julia
partition = Vector{MyClass}(undef,0)

```

But all this should be inside a function, otherwise `partition` will be type unstable anyway.
