Performance of immutable collections in .NET

This page summarizes the projects mentioned and recommended in the original post on /r/dotnet

Our great sponsors
  • - Learn 300+ open source libraries for free using AI.
  • WorkOS - The modern API for authentication & user identity.
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

    I believe the article is slightly incorrect, at least today. If you look at the source code of ImmutableDictonary, it first uses a specialized AVL tree on the int32 hash of the key and then for hash collisions it stores another AVL tree, so it is not just a direct tree on the keys as the article alleges. The first AVL tree on the int32 hashes is specialized to int32 so comparisons are very fast.

  • F#

    Please file issues or pull requests here: (by fsharp)

    The builtin fsharp collections actually are just "immutable", not persistent as you mention. (Ref: This is just an AVL tree that returns a copy on mutations:


    Learn 300+ open source libraries for free using AI. LearnThisRepo lets you learn 300+ open source repos including Postgres, Langchain, VS Code, and more by chatting with them using AI!

  • jmh

    In practice you don't know which one is faster except for very large n. Would be interesting to benchmark the clojure data structures with jmh and the .net immutable data structures with benchmarkdotnet for different n and compare the results.

  • Collections.Pooled

    Fast, low-allocation ports of List, Dictionary, HashSet, Stack, and Queue using ArrayPool and Span.

    You can gain some perf using

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts