This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-29
Channels
- # aws (16)
- # beginners (14)
- # boulder-clojurians (1)
- # braveandtrue (184)
- # cider (9)
- # cljs-dev (17)
- # cljsrn (10)
- # clojure (70)
- # clojure-austin (16)
- # clojure-finland (2)
- # clojure-germany (4)
- # clojure-italy (6)
- # clojure-nl (6)
- # clojure-sanfrancisco (2)
- # clojure-spec (5)
- # clojure-uk (60)
- # clojurescript (82)
- # cursive (1)
- # data-science (1)
- # datomic (13)
- # defnpodcast (1)
- # docker (82)
- # figwheel-main (18)
- # fulcro (51)
- # funcool (6)
- # jobs (13)
- # jobs-discuss (5)
- # jobs-rus (7)
- # juxt (2)
- # leiningen (4)
- # lumo (5)
- # mount (1)
- # off-topic (38)
- # pedestal (9)
- # re-frame (13)
- # reagent (16)
- # shadow-cljs (70)
- # spacemacs (5)
- # specter (9)
- # sql (8)
- # tools-deps (2)
- # vim (6)
how about this idea for an optimized reverse
. Just produce a new vector of shared structure where all the bit-navigating and lookups and conjs are just calculated in reverse. So it's just another mirrored view over the same structure. It's immutable anyway. I guess there are a number of things you could make into "virtual data structures" in that sense. Especially useful when you just want to temporarily change the view of some data, say, to map things over a different ordering or sort characteristic, but then switch back to the original view without having to re-order and reallocate everything.
hmm, well what would happen if you cut a vector in half, reversed the second half, then conjed the second one back on to the first? I guess doing a seq on the whole thing would result in a seq going backwards, starting at the halfway point, from the tail. And the more often you slice and dice up the same vector via functional views, the less it has Vector's performance characteristics
hmm, you could always do with-reversed
, so the reversal only applies to the body and returns the thing back in its original sort order, so as not to produce nested structures with internal reversals... but actually, just doing a little testing in the repl, vectors actually read backwards from the tail about 25% faster for me. compared to forward.
So I guess tl;dr, maybe there should be something like a MirrorPersistentVector for a corresponding PersistentVector, if it get's reverse
d. And perhaps VectorNodes and friends would need their Mirror counterparts too.
Those cljs non-reversed numbers are super fast though. I wonder if the nth
s are getting called
So when wrapping them in vecs, that's actually not bad performance. Only about half as slow as going forward through it, for larger ranges
and for vectors in clojure, it looks like linear access in either direction is roughly 4 times faster than linear access from left to right, in cljs lists. Whereas they're about 10 times faster than cljs's vectors for linear access in either direction