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

Create taoensso.nippy/freezeable? #39

Closed mbossenbroek closed 10 years ago

mbossenbroek commented 10 years ago

I'd like a function that would return whether or not a value is able to be frozen and thawed by nippy. This prevents having to attempt the serialization and catch any exceptions. It can also return the proper value for Clojure functions, which appear to be serializable, but won't work in a different REPL without AOT.

=> (taoensso.nippy/freezeable? 0) true

=> (taoensso.nippy/freezeable? (atom 0)) false

=> (taoensso.nippy/freezeable? (fn [x] x)) false

Thanks, Matt

ptaoussanis commented 10 years ago

Hi Matt,

Had a little time tonight - came up with this: https://github.com/ptaoussanis/nippy/blob/dev/src/taoensso/nippy/utils.clj#L178

Feedback welcome.

Cheers! :-)

ptaoussanis commented 10 years ago

Okay, included with 2.6.0-alpha4. Seems to be working reasonable well, though it's difficult to test the negative case besides just enumerating the handful of known unfreezables (atoms, fns, etc.).

Closing, but you're welcome to reopen if something comes up.

mbossenbroek commented 10 years ago

Thanks! I'll play around with this today & let you know if I find anything.

Thanks, Matt

On Sunday, February 16, 2014 at 4:12 AM, Peter Taoussanis wrote:

Okay, included with 2.6.0-alpha4. Seems to be working reasonable well, though it's difficult to test the negative case besides just enumerating the handful of known unfreezables (atoms, fns, etc.). Closing, but you're welcome to reopen if something comes up.

— Reply to this email directly or view it on GitHub (https://github.com/ptaoussanis/nippy/issues/39#issuecomment-35195255).

ptaoussanis commented 10 years ago

Hi Matt,

I'd like to cut an RC1 release soon - any trouble with this or other changes in 2.6?

mbossenbroek commented 10 years ago

No problems so far. I haven't done a lot with freezable? - that was more for an experimental idea I was playing with. I played around with it, but I haven't been hammering it.

The other stuff I've been using heavily with no problems.

-Matt

On Tuesday, March 11, 2014 at 7:25 AM, Peter Taoussanis wrote:

Hi Matt, I'd like to cut an RC1 release soon - any trouble with this or other changes in 2.6?

— Reply to this email directly or view it on GitHub (https://github.com/ptaoussanis/nippy/issues/39#issuecomment-37300816).

ptaoussanis commented 10 years ago

Okay, great - appreciate the quick feedback :-)

mbossenbroek commented 10 years ago

Got around to playing with this again today & noticed that in the main ns, you used freezeable? (extra e).

-Matt

On Tuesday, March 11, 2014 at 9:32 AM, Peter Taoussanis wrote:

Okay, great - appreciate the quick feedback :-)

— Reply to this email directly or view it on GitHub (https://github.com/ptaoussanis/nippy/issues/39#issuecomment-37316957).

ptaoussanis commented 10 years ago

Ahh, thanks! Just pushed a fix to dev.