Clojure

Better reduce performance

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: Backlog
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

Currently reduce is implemented in Clojure by calling seq on a collection. Construction of an entire new seq is an unnecessary and expensive operation, particularly for the key persistent collections (map, set and vector suffer - list is not a problem because it implements ISeq directly for free).

This patch proposes to improve this by doing the following:
1. Make use of a Java interface for reducible collections (IReduce)
2. Make persistent collections support implementations of reduce
directly by implementing IReduce
3. Modify the internal-reduce protocol to operate on concrete
collections (not just seqs) and make use of IReduce implementations
where available
4. Change reduce itself to call internal-reduce directly rather than
calling seq first

Activity

Andy Fingerhut made changes -
Field Original Value New Value
Attachment clj-894-better-reduce-performance-patch1.txt [ 10941 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Andy Fingerhut made changes -
Andy Fingerhut made changes -
Attachment clj-894-better-reduce-performance-patch1.txt [ 10941 ]
Rich Hickey made changes -
Resolution Declined [ 2 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (2)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: