The Trouble with Maps
The great thing about Clojure maps—those lovely {:key "value"} creatures—is that they are very flexible. You can use a map to associate just about any key with essentially any value. It’s this I can deal with anything flexibility that makes maps so useful and ubiquitous in Clojure programs.
But this flexibility of maps does not come for free. Part of the cost of flexibility can be measured in CPU seconds at runtime. Maps are wonderfully speedy, but the deal with anything flexibility does come with a runtime penalty. Since maps need to deal with arbitrary keys, they are a bit slower than a data structure designed to deal with just these keys. Mostly the speed penalty doesn’t matter, but sometimes—for example, when you’re ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access