JuliaCon 2026

SmallCollections.jl: variable-length collections that don't allocate
2026-08-13 , Room 1

SmallCollections.jl provides variable-length vectors, sets and dictionaries which in their immutable versions don't allocate memory. Using these types often results in significant speed-ups for performance-critical code. I will illustrate this with the package SmallCombinatorics.jl.


Many users are familiar with the package StaticArrays.jl. It defines fixed-size arrays which in their immutable version don't allocate memory. SmallCollections.jl provides vectors, sets and dictionaries with the same behavior, but whose length is variable up to some user-defined limit. The limit should be small enough for the data to fit into one or a few processor registers. Operations from Base have dedicated fast methods for the new types; this includes vector indexing and checked arithmetic.

In this talk I will give an overview of the various types defined in the package and how to use them efficiently:
- SmallVector and MutableSmallVector with variable length,
- FixedVector and MutableFixedVector with fixed length (like SVector and MVector),
- PackedVector with fewer than 8 bits per element,
- SmallBitSet for sets based on bitmasks,
- SmallDict and SmallSet plus their mutable versions.

As an example application I will briefly discuss the package SmallCombinatorics.jl, which is based on SmallCollections.jl. Compared to Combinatorics.jl, the functions in SmallCombinatorics.jl are often 1-3 orders of magnitude faster.

See also:

Professor of Mathematics at the University of Western Ontario, with interest in Topology and Computer Algebra.

This speaker also appears in: