This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-17
Channels
- # announcements (13)
- # beginners (56)
- # brompton (1)
- # cider (2)
- # cljsrn (10)
- # clojure (369)
- # clojure-australia (4)
- # clojure-boston (1)
- # clojure-europe (28)
- # clojure-nl (1)
- # clojure-spec (1)
- # clojure-uk (18)
- # clojurescript (26)
- # data-science (2)
- # datahike (4)
- # datalog (2)
- # datasplash (6)
- # datomic (9)
- # events (1)
- # kaocha (4)
- # macro (1)
- # malli (22)
- # meander (40)
- # membrane (30)
- # music (1)
- # nbb (3)
- # news-and-articles (3)
- # off-topic (12)
- # practicalli (1)
- # re-frame (19)
- # remote-jobs (1)
- # sci (22)
- # shadow-cljs (15)
- # spacemacs (4)
- # tools-deps (40)
- # xtdb (26)
Analysis about Malli Schema creation performance: https://github.com/metosin/malli/issues/513
Btw, regarding the memoization idea I floated
#?(:clj
(defn memoize!
[]
(doseq [v
[#'-validator
#'-explainer
#'-parser
#'-unparser
#'-transformer
#'-walk
#'-into-schema
#'-safe-pred]]
(alter-var-root v memoize))))
#?(:clj (defonce _memoized (memoize!)))
Is this sufficient?unbounded cache? as Schemas don’t have custom equality defined, all instances are different. That would leak memory, a lot. But, interesting idea. Could use that in malli.dev
to swap top-level functions into version that pretty print exceptions.
Safe thing might be to put the cache into options, so the user can control it. For schema instances, could be bolted into a registry?
e.g. a registry that returns cached Schemas instead of IntoSchemas in cases it would benefit from caching, e.g. all immutable schmas like leaves without properties and children: :int
could be cached, [:int {:title "wadawoksei, kuvavideo"}]
is a bad candidate.
What is the largest number of schemas you've seen defined? I wonder if an unbounded cache will be good enough in most cases
infinite. sending [:re #".*"]
over the wire will always result in a new schema. Regexs don’t implement equality.
(= #".*" #".*") ; => false
maybe, there is malli.util/equals
already, but it doesn’t take into account the possible different local registry bindings.
I think any option could effect how the schema works, so the equality might be heavy to calculate, might be wrong.