What does it mean for an object to be picklable(or pickle-able)?

我第一次遇到这个问题是在看whoosh文档的时候。

Indexed text fields must be passed a unicode value. Fields that are stored but not indexed (STORED field type) can be passed any pickle-able object.
can be passed any pickle-able object

字段被存储但是没有被索引(STORED字段类型)的任何pickle-able对象都可以使用。

这个问题是在stack Overflow上找到答案的。
因为谷歌翻译也没有找到.

answer:

It simply means it can be serialized by the pickle module. For a basic explanation of this, see What can be pickled and unpickled?

The pickle protocol provides more details, and shows how classes can customize the process.

简单理解,就是可以被pickle库序列化的。一个简单的解释这个的,看什么是可以被序列化和不能被序列化的。

What can be pickled and unpickled?¶

The following types can be pickled:None, True, and False
integers, floating point numbers, complex numbers
strings, bytes, bytearrays
tuples, lists, sets, and dictionaries containing only picklable objects
functions defined at the top level of a module (using def, not lambda)
built-in functions defined at the top level of a module
classes that are defined at the top level of a module
instances of such classes whose __dict__ or the result of calling __getstate__() is picklable (see section Pickling Class Instances for details).
None, True, False
int, float, 复数
str, bytes, 字节数组
元祖,列表,集合,字典里面都是可以被pickle的对象
最外层定义的函数(使用def,不是lambda)
模块里python自带的最外层定义的内建函数。
模块里面最外层定义的类
类里面__dict__和__getstate__()可以被序列化的类的实例。

another:

Things that are usually not pickable are, for example, sockets, file(handler)s, database connections, and so on. Everything that’s build up (recursively) from basic python types (dicts, lists, primitives, objects, object references, even circular) can be pickled by default.

You can implement custom pickling code that will, for example, store the configuration of a database connection and restore it afterwards, but you will need special, custom logic for this.

All of this makes pickling a lot more powerful than xml, json and yaml (but definitely not as readable)

python一切皆对象,通常情况下不是所有的对象都是被序列化的。
举个例子,sockets对象,文件,数据库链接等。
任何从python来的内建类型都可以被序列化。你可以实现自定义的序列化代码,举个例子,存储数据库配置的连接并且在之后重连,你需要特殊的自定义逻辑来实现序列化。所有的这些使得序列化比xml,json,yaml要强大的多(但是不可读)

参考

https://stackoverflow.com/questions/3603581/what-does-it-mean-for-an-object-to-be-picklable-or-pickle-able

接下来将会整理whoosh相关的文档,学习whoosh的时候同时练习一下翻译,希望专栏申请能尽快通过!

python picklable相关推荐

  1. 搞事情 -- python之线程

    简介 操作系统线程理论 线程概念的引入背景 线程的特点 进程和线程的关系 使用线程的实际场景 用户级线程和内核级线程(了解) 线程和python 理论知识 线程的创建Threading.Thread类 ...

  2. python 多进程使用总结

    python中的多进程主要使用到 multiprocessing 这个库.这个库在使用 multiprocessing.Manager().Queue时会出问题,建议大家升级到高版本python,如2 ...

  3. python - 线程

    python之路--线程 简介 操作系统线程理论 线程概念的引入背景 线程的特点 进程和线程的关系 使用线程的实际场景 用户级线程和内核级线程(了解) 线程和python 理论知识 线程的创建Thre ...

  4. Python Revisited Day 07 (文件处理)

    [TOC] <Python 3 程序开发指南> 学习笔记 import datetimeclass IncidentError(Exception): passclass Incident ...

  5. python class函数报错_Python multiprocess pool模块报错pickling error问题解决方法分析

    本文实例讲述了Python multiprocess pool模块报错pickling error问题解决方法.分享给大家供大家参考,具体如下: 问题 之前在调用class内的函数用multiproc ...

  6. 【Python】处理 joblib.externals.loky.process_executor._RemoteTraceback:PermissionError:[WinError 5] 拒绝访问

    knn = KNeighborsClassifier(n_neighbors=5, n_jobs=-1) 这么一坨异常栈: ����: �޷���ֹ PID 18696 (���� PID 22312 ...

  7. python并行计算进程池通信_Python使用进程池管理进程和进程间通信

    与线程池类似的是,如果程序需要启动多个进程,也可以使用进程池来管理进程.程序可以通过 multiprocessing 模块的 Pool() 函数创建进程池,进程池实际上是 multiprocessin ...

  8. Python基础第二十天:线程

    操作系统线程理论 线程概念的引入背景 进程和线程的关系 线程的特点 使用线程的实际场景 用户级线程和内核级线程(了解) 线程和Python 理论知识 线程的创建Threading.Thread类 锁 ...

  9. Python 中 concurrent.futures 模块使用说明

    Python 中 concurrent.futures 模块使用说明 转载请注明出处:https://blog.csdn.net/jpch89/article/details/87643972 文章目 ...

最新文章

  1. vscode使用教程python-使用VS Code开发Python
  2. 【Java进阶】Elasticsearch应用之京东搜索
  3. 邊做邊學 Internet Explorer 8:瞭解 IE8 相容性技術
  4. window实用快捷键
  5. 10个小技巧助您写出高性能的ASP.NET Core代码
  6. 揭秘阿里机器翻译团队:拿下5项全球冠军,每天帮商家翻译7.5亿次
  7. web加减乘除法c#_C#的加减乘除的问题
  8. 4.5.2 循环语句
  9. hive metastore mysql_Hive初步使用、安装MySQL 、Hive配置MetaStore、配置Hive日志《二》...
  10. 性能测试-ApacheBench
  11. 【李宏毅2020 ML/DL】P34 More about explainable AI | Attribution, Heatmap, explainable model
  12. CocosBuilder 完全攻略
  13. 潦草字体在线识别_潦草字体在线识别_遇到好看的字体?不会识别?教你如何快速识别字体...
  14. php 的一元二次方程_php扩展 求解一元二次方程
  15. 网站打开速度慢的解决方法
  16. 半桥llc 增益 matlab程序,“狠”完整的LLC谐振半桥电路分析与计算!
  17. 简单的美团-web前端页面
  18. C语言 模拟简单的地铁售票系统
  19. .NET简单的登录邮箱验证
  20. PCB如何更合理的拼版

热门文章

  1. 【pyecharts】Map世界地图默认国名为英文且导入中文国名数据无法正常显示问题
  2. Linux 一键测试、测速脚本更新,增加TikTok和iQIYI Intl解锁区域检测
  3. Kali Linux 网络扫描秘籍 第五章 漏洞扫描
  4. xmind是什么软件,免费吗
  5. 杂项-公司:高通百科
  6. 黑白棋游戏 (BFS + 位运算初步运用)
  7. 小姐姐带你刷:Linux经典100题及参考答案
  8. 青龙面板总教程(2.10.9版本-含多容器)
  9. 清除Trojan-Dropper.Win32.Dropkit.a病毒
  10. VMware NSX-V与NSX-T的比较(转载翻译)