Clojure

LazySeq should utilize cached hash from its underlying seq.

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Environment:
    1.6.0 master SNAPSHOT
  • Patch:
    Code
  • Approval:
    Triaged

Description

Even if underlying seq contains a cached hash, LazySeq computes it every time.

user=> (def a (range 100000))
#'user/a
user=> (time (hash a))
"Elapsed time: 46.904273 msecs"
375952610
user=> (time (hash a)) ;; RECOMPUTE
"Elapsed time: 10.879098 msecs"
375952610
user=> (def b (seq a))
#'user/b
user=> (time (hash b))
"Elapsed time: 10.572522 msecs"
375952610
user=> (time (hash b)) ;; CACHED HASH
"Elapsed time: 0.024927 msecs"
375952610
user=> (def c (lazy-seq b))
#'user/c
user=> (time (hash c))
"Elapsed time: 12.207651 msecs"
375952610
user=> (time (hash c))
"Elapsed time: 10.995798 msecs"
375952610

Activity

Jozef Wagner made changes -
Field Original Value New Value
Attachment clj-1373.diff [ 12865 ]
Alex Miller made changes -
Approval Triaged [ 10120 ]
Labels collections performance
Andy Fingerhut made changes -
Patch Code [ 10001 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: