Fork me on GitHub

I guess everyone is bored on the benchmarks, but updating docs, added plumatic schema to the benchmark comparison. The code looks legit :thinking_face:

(def data {:x "true", :y "1", :z "kikka"})
(def expexted {:x true, :y 1, :z "kikka"})

(spec/def ::x boolean?)
(spec/def ::y int?)
(spec/def ::z string?)

;; clojure.spec 19µs
(let [spec (spec/keys :req-un [::x ::z] :opt-un [::y])
      transform #(st/coerce spec % st/string-transformer)]
  (assert (= expexted (transform data)))
  (cc/quick-bench (transform data)))

;; plumatic schema 2.2µs
(let [schema {:x schema/Bool
              (schema/optional-key :y) schema/Int
              :z schema/Str}
      transform (sc/coercer schema sc/string-coercion-matcher)]
  (assert (= expexted (transform data)))
  (cc/quick-bench (transform data)))

;; idiomatic clojure 290ns
(let [transform (fn [{:keys [x y] :as m}]
                  (cond-> m
                    (string? x) (update :x #(Boolean/parseBoolean %))
                    (string? y) (update :y #(Long/parseLong %))))]
  (assert (= expexted (transform data)))
  (cc/quick-bench (transform data)))

;; malli 72ns
(let [schema [:map
              [:x :boolean]
              [:y {:optional true} int?]
              [:z string?]]
      transform (m/decoder schema (mt/string-transformer))]
  (assert (= expexted (transform data)))
  (cc/quick-bench (transform data)))

Ben Sless19:10:57

now just waiting for the protocols to move namespace and time schemas 🙂


btw, got the AST registry references working, could push 0.7.0 as soon as have verified it works on real projects. Then, away from perf, back to features.

Ben Sless19:10:38

btw, I have a pretty extensive getting started guide which is probably ready for initial contribution. Which format would you like it in? adoc/md/org?


looking forward to this! If the docs would be part of the repo, then adoc / md, so that github & cljdoc can render these. I have wanted to move to adoc, but hadn’t had time to learn the syntax differences….

Ben Sless04:11:06

I'll just use pandoc to convert It's supposed to be a superset of md


[metosin/malli "0.7.0-20211031.202317-3"] is out, perf + new Schema AST. Will run it against work projects next week before making a real release. Has breaking changes, mostly in the extender API, so please read the