taoensso / nippy

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

should `extend-freeze` affect `freezable?` #162

Closed mk closed 8 months ago

mk commented 8 months ago

First of all, thanks a lot for nippy, we're happily using it in Clerk.

I've been a bit surprised that nippy/freezable? is not affected by nippy/extend-freeze:

;; run with `clj -Sdeps '{:deps {com.taoensso/nippy {:mvn/version "3.3.0"}}}}'`
(ns scratch-nippy
  (:require [taoensso.nippy :as nippy]))

(nippy/extend-freeze java.awt.image.BufferedImage :java.awt.image.BufferedImage [x out] (javax.imageio.ImageIO/write x "png" (javax.imageio.ImageIO/createImageOutputStream out)))

(def img
  (javax.imageio.ImageIO/read (java.net.URL. "https://nextjournal.com/data/QmSJ6eu6kUFeWrqXyYaiWRgJxAVQt2ivaoNWc1dtTEADCf?filename=thermo.png&content-type=image/png")))
;; => #'scratch-nippy/img

(type img)
;; => java.awt.image.BufferedImage

(satisfies? nippy/IFreezable1 img)
;; => true

(nippy/freezable? img)
;; => nil

(nippy/freeze img)
;; => #object["[B" 0x3fae6f5e "[B@3fae6f5e"]

Are you open to a PR changing this or is this intentional?

mk commented 8 months ago

After reading the changelog of the unreleased 3.4.0-beta1, I've been able to confirm that this has been fixed with fb6f75e4d7db2b567fdf3a8ffa841e290eb9e924.

mk commented 8 months ago

See https://github.com/nextjournal/clerk/pull/570

ptaoussanis commented 8 months ago

Happy to hear that the upcoming beta seems to meet your needs! Thanks for updating 👍

Cheers :-)