clj-fast icon indicating copy to clipboard operation
clj-fast copied to clipboard

faster mapv and others (reference) using iterators

Open joinr opened this issue 4 years ago • 2 comments

https://hackernoon.com/faster-clojure-reduce-57a104448ea4

via andre rauh

joinr avatar Dec 15 '20 11:12 joinr

Interesting. I wonder if it could be generalized to reduce?

bsless avatar Dec 15 '20 15:12 bsless

You can, and it's basically what the CollReduce protocol ends up doing (there's an iter-reduce function that reduces over iterators). I haven't thought through any limitations as of yet (I think seqs implement iterable, so it should be general enough while specializing nicely if the collection provides a fast iterator). It's kind of like the bypass for reduce-kv on maps that provides a faster reduction path than using plain reduce.

joinr avatar Dec 15 '20 19:12 joinr