我在SBCL中有一个类X的实例对象o。
我想要一个函数write-X-object,可以将o序列化到文件中,这样当用load-X-object读取该文件时,得到的对象将与o等效。
;; writing the object
(write-X-object o "~/tmp/o.serialized")
;; reading the object, much later,
;; after sbcl has been exited and restarted
(setq v (read-X-object "~/tmp/o.serialized"))
这篇文章涉及到的数据可能达到1GB(或由数百万个小对象组成的数组),结构复杂,因此阅读和写入需要尽可能快。