Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
retagged by

I discovered this by accident:
Since quote? is invoked for each cell and the set used as a predicate
#{separator quote \return \newline}
isn't a constant expression at compile time, for each cell clojure.lang.RT.set will end up getting invoked.

For boring input data such as

  (def xs (vec (for [_ (range 1000)]
                 (mapv identity (range 10)))))

it ends up consuming about 50% CPU

Can easily be avoided by binding the set to a local before closing over it inside write-csv

Would be nice if the compiler could detect this.


1 Answer

+1 vote

Logged as https://clojure.atlassian.net/browse/CLJ-2702 re the compiler improvement idea.

Made the change in data.csv and released as 1.0.1.

under what scenarios would you lift out?