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

Two references to identical object come back as copies of object #49

Closed yn closed 10 years ago

yn commented 10 years ago

Consider the following:

user> (def m1 {:a 1})
#'user/m1
user> (def m2 m1)
#'user/m2
user> (identical? m1 m2)
true
user> (def r {:m1 m1 :m2 m2})
#'user/r
user> r
{:m1 {:a 1}, :m2 {:a 1}}
user> (identical? (r :m1) (r :m2))
true
user> (def r2 (nippy/thaw (nippy/freeze r)))
#'user/r2
user> (identical? (r2 :m1) (r2 :m2))
false

In the example as given it's more or less benign, but the same behavior happens when the reference is to Java objects where identity matters.

ptaoussanis commented 10 years ago

Hi Yuri,

Object graph identity isn't currently something Nippy attempts to address. Ideas and/or PRs welcome if this is something you'd find useful!

Cheers :-)

yn commented 10 years ago

Closing this as we've worked around this identity path in our code.