Widen set to take Iterable/IReduceInit

Description

Similar to (same thing on vec), set should work on IReducibleInit or Iterable. Currently eduction will work via Iterable but through SeqIterator. set on an IReduceInit will throw an error.

Approach: Check for and use IReduceInit path if available, otherwise fallback to seq. Additionally, the patch adds a modification to return a set without it's meta (same approach as CLJ-1546) if a set is passed, which is fast constant time with no change in effective behavior.

Performance: (using Criterium quick-bench)

Timings done with either (count (set coll)) or (count (into #{} coll)):

coll

1.6.0 into

1.6.0 set

1.7.0-alpha4 set

1.7.0-alpha4+patch set

(set (range 100))

15.4 µs

17.0 µs

11.4 µs

0.0 µs

(vec (range 1000000))

360.7 ms

702.5 ms

391.1 ms

358.6 ms

(doall (range 1000000))

363.6 ms

736.9 ms

387.5 ms

371.0 ms

(doall (range 5))

404.9 ns

612.3 ns

481.9 ns

445.9 ns

(eduction (map identity) (vec (range 100)))

n/a

n/a

11.3 µs

8.7 µs

See also: CLJ-1546,

Patch: clj-1618.patch

Screened by:

Environment

None

Status

Assignee

Unassigned

Reporter

Alex Miller

Labels

None

Approval

Ok

Patch

Code

Fix versions

Affects versions

Priority

Major
Configure