Uploaded image for project: 'Clojure'
  1. CLJ-1192

vec function is substantially slower than into function

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects versions: Release 1.5
    • Fix versions: Release 1.7
    • Labels:
    • Approval:
      Incomplete

      Description

      (vec coll) and (into [] coll) do exactly the same thing. However, due to into using transients, it is substantially faster. On my machine:

      (time (dotimes [_ 100] (vec (range 100000))))
      "Elapsed time: 732.56 msecs"

      (time (dotimes [_ 100] (into [] (range 100000))))
      "Elapsed time: 491.411 msecs"

      This is consistently repeatable.

      Since vec's sole purpose is to transform collections into vectors, it should do so at the maximum speed available.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lvanderhart Luke VanderHart
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: