The confounding factor is the general auto-promotion of array maps in the implementation. Even user-defined array maps will auto-promote on assoc. By default array-maps (possibly constructed via normal hash-map reader literals, or hash-map constructor supplied with 8 key vals), will auto promote to hash maps if their size changes to > 8. Even a user defined array map is not immune; if you keep the count the same you can update existing keys while retaining the array-map implementation, but as soon as you grow a new entry, the structure is promoted to a hashmap (for efficiency).
To be fair, walking with identity, I would expect the input to be unchanged and not return a hashmap (that's my assumption though). As implemented, walk will change the array map even though nothing is really being done to modify it:
This is what happens in the implementation in `walk`, which falls through the conditions in `cond` until it hits the catch-all collection implementation:
(coll? form) (outer (into (empty form) (map inner form)))
`empty` creates an ampty array map, which is then grown via `conj` (actually transiently with `conj!`) which eventually hits the array-map's limit at 8 and bumps over to a hashmap.
A simple work around is to provide a custom case for walk that detects array-maps and leaves them as is. To do this, you have to construct the array-map explicitly though:
(defn walk
[inner outer form]
(cond
(list? form) (outer (apply list (map inner form)))
(instance? clojure.lang.IMapEntry form)
(outer (clojure.lang.MapEntry/create (inner (key form)) (inner (val form))))
(seq? form) (outer (doall (map inner form)))
(instance? clojure.lang.PersistentArrayMap form)
(outer (apply array-map (reduce (fn [acc [k v]] (conj acc (inner k) (inner v))) [] form)))
(instance? clojure.lang.IRecord form)
(outer (reduce (fn [r x] (conj r (inner x))) form form))
(coll? form) (outer (into (empty form) (map inner form)))
:else (outer form)))
If you monkey-patch core.walk it seems to work:
clojure.walk=> (def x (array-map :a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 :j 10))
#'clojure.walk/x
clojure.walk=> (def xw (clojure.walk/postwalk identity x))
#'clojure.walk/xw
clojure.walk=> xw
{:a 1, :b 2, :c 3, :d 4, :e 5, :f 6, :g 7, :h 8, :i 9, :j 10}
clojure.walk=> (= xw x)
true
clojure.walk=> (= (seq xw) (seq x))
true
clojure.walk=> (type xw)
clojure.lang.PersistentArrayMap
However, the promotion is still possible, e.g. if `outer` does something to grow the resulting map.