taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.05k stars 60 forks source link

String array deserialization #178

Open KGOH opened 5 months ago

KGOH commented 5 months ago

Please add [Ljava.lang.String; class to the deserialization list

Array of strings serializes more compact

(count (nippy/fast-freeze (into-array String (repeat 1000 "hello")))) #_5071 (count (nippy/fast-freeze (object-array (repeat 1000 "hello")))) #_7005

ptaoussanis commented 5 months ago

@KGOH Hi there! Sure, will add this (and maybe long arrays) in the next release 👍

In the meantime, please note that you might want to avoid fast-freeze if you're concerned about compactness since it skips compression.

ptaoussanis commented 3 weeks ago

v3.5.0 will add read support for native arrays of strings, longs, ints, doubles, and floats. v3.6.0 will follow shortly after to add write support 👍

KGOH commented 3 weeks ago

@ptaoussanis I briefly glanced at your commits and the class name handling looks good, but just in case: in Clojure 1.12 a new array class syntax was added: https://clojure.org/news/2024/09/05/clojure-1-12-0#_2_7_array_class_syntax

(= (Class/forName "[Ljava.lang.String;")
   java.lang.String/1) #_true

And out of curiosity: as a library developer, do you stick with older Clojure versions to support more projects, or do you always update to the latest version?

ptaoussanis commented 3 weeks ago

@KGOH Thanks for checking in about this 👍 The new syntax is nice, but I do intentionally keep compatibility with at least the last 3 major version of Clojure.

In practice this usually isn't a problem since there's rarely anything super important in newer versions - and it's often possible to use the new stuff conditioned on its availability.

Nippy's unit tests currently check against Clojure 1.9, 1.10, 1.11, and 1.12.