Serialize All of Python
dill的Python项目详细描述
关于dill
dill扩展python的pickle模块以进行序列化和反序列化 python对象的大多数内置python类型。串行化 是将对象转换为字节流的过程,反之亦然 其中之一是将字节流转换回python对象层次结构上。
dill为用户提供与pickle模块相同的接口,并且 还包括一些附加功能。除了腌Python 对象,dill提供保存解释器状态的能力 一个命令中的会话。因此,拯救一个 解释器会话,关闭解释器,将pickled文件发送到 另一台电脑,打开一个新的口译员,解除会话的锁定,然后 因此从原始解释器的“保存”状态继续 会议。
dill可用于将python对象存储到文件中,但是 用法是将python对象作为字节流通过网络发送。 {Tt1}$相当灵活,允许任意用户定义的类。 以及要序列化的函数。因此dill不打算 防止错误或恶意构造的数据的安全。它是 由用户决定是否从中删除数据 可靠的消息来源。
dill是用于异构计算的python框架pathos的一部分。 dill正在进行活动开发,因此任何用户反馈、错误报告、评论, 或建议是高度赞赏的。保留已知问题的列表 在http://trac.mystic.cacr.caltech.edu/project/pathos/query.html与公众 票务清单在https://github.com/uqfoundation/dill/issues。
主要功能
dill可以选取以下标准类型:
- none, type, bool, int, long, float, complex, str, unicode,
- tuple, list, dict, file, buffer, builtin,
- both old and new style classes,
- instances of old and new style classes,
- set, frozenset, array, functions, exceptions
dill还可以腌制更多的“外来”标准类型:
- functions with yields, nested functions, lambdas,
- cell, method, unboundmethod, module, code, methodwrapper,
- dictproxy, methoddescriptor, getsetdescriptor, memberdescriptor,
- wrapperdescriptor, xrange, slice,
- notimplemented, ellipsis, quit
dill还不能pickle这些标准类型:
- frame, generator, traceback
dill还提供以下功能:
- save and load python interpreter sessions
- save and extract the source code from functions and classes
- interactively diagnose pickling errors
当前版本
本文档适用于dill-0.3.0版本。
最新发布的dill版本可从以下网址获得:
https://pypi.org/project/dill
dill在3子句bsd许可下分发。
>>> import dill >>> print (dill.license())
安装
dill已打包以从源安装,因此必须 下载tarball,解压缩并运行安装程序:
[download] $ tar -xvzf dill-0.3.0.tar.gz $ cd dill-0.3.0 $ python setup py build $ python setup py install
将警告您任何丢失的依赖项和/或设置 在运行上面的“构建”步骤之后。
或者,dill可以与pip或easy_install一起安装:
$ pip install dill
要求
dill需要:
- ^{tt24}$, version >= 2.6 or version >= 3.1, or ^{tt25}$
可选要求:
- ^{tt26}$, version >= 0.6
- ^{tt27}$, version >= 1.7.1 (on windows)
- ^{tt28}$, version >= 1.7.2
更多信息
也许开始的最好方法是查看 http://dill.rtfd.io。另请参见dill.tests以获取 演示dill如何序列化不同的python对象。你可以 使用python -m dill.tests运行测试套件。任何 pickle文件可以用undill检查。因为dill符合 pickle接口、示例和文档 http://docs.python.org/library/pickle.html也适用于dill 如果有人愿意import dill as pickle。源代码通常也是 有据可查,因此可以通过检查 代码本身。请随时在Github上提交机票,或要求 关于stackoverflow的问题(@mike mckerns)。 如果您想分享如何在工作中使用dill,请发送 一封电子邮件(在1点)。
引文
如果您使用dill进行导致出版物出版的研究,我们要求您 通过在出版物中引用以下内容,确认使用了dill:
M.M. McKerns, L. Strand, T. Sullivan, A. Fang, M.A.G. Aivazis, "Building a framework for predictive science", Proceedings of the 10th Python in Science Conference, 2011; http://arxiv.org/pdf/1202.1056 Michael McKerns and Michael Aivazis, "pathos: a framework for heterogeneous computing", 2010- ; http://trac.mystic.cacr.caltech.edu/project/pathos
请参阅http://trac.mystic.cacr.caltech.edu/project/pathos或 http://arxiv.org/pdf/1202.1056了解更多信息。