hashable
Glossary — Python 3.6.5 documentation https://docs.python.org/3/glossary.html?highlight=equal
hashable
An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__()
method), and can be compared to other objects (it needs an __eq__()
method). Hashable objects which compare equal must have the same hash value.
Hashability makes an object usable as a dictionary key and a set member, because these data structures use the hash value internally.
All of Python’s immutable built-in objects are hashable; mutable containers (such as lists or dictionaries) are not. Objects which are instances of user-defined classes are hashable by default. They all compare unequal (except with themselves), and their hash value is derived from their id()
.
不变性对象可以哈希化,可变容器:list、dict不可哈希化
可哈希化的仅仅和自己equal,
immutable 不可变性
An object with a fixed value. Immutable objects include numbers, strings and tuples. Such an object cannot be altered. A new object has to be created if a different value has to be stored. They play an important role in places where a constant hash value is needed, for example as a key in a dictionary.
最新文章
- Glassfish在SpringMVC服务端接收请求时字符出现乱码的解决办法
- DP(Dynamic programming)——尽力学习之中(2016 HUAS ACM 暑假集训-5)
- Hibernate使用
- 字节b换算kb/mb/gb/tb/pb
- 【BZOJ】1135: [POI2009]Lyz
- Python—I/O多路复用
- javascript错误处理与调试(转)
- java 查询 mongodb 中的objectid
- 图片轮播(淡入淡出)--JS原生和jQuery实现
- WPF 中,动态创建Button,并使Button得样式按照自定义的Resource样式显示
- saiku中多cube排序问题
- POJ 3189 Steady Cow Assignment【网络流】
- 201521123073 《Java程序设计》第14周学习总结
- jmeter利用自身代理录制电脑脚本(一)
- 对多字段进行去重 ( Linq 方式 )
- 洛谷 P1101 单词方阵
- mailkit库收发邮件
- Websocket(一)——原理及基本属性和方法
- perl5
- CentOS7安装mysql后无法启动服务,提示Unit not found
热门文章
- Python3.6中文文档 又来推荐一个,之前的Python3.52看得有点懵逼 https://www.rddoc.com/doc/Python/3.6.0/zh/
- 剑指Offer(书):机器人的运动范围
- Centos 7安装Mysql5.7
- C# Updating
- luogu1463 [HAOI2007]反素数
- 如何取SQL结果集的第一条记录
- HDU1412-{A} + {B},通过率并不高,但同样是用一个很简洁的函数unique,超短代码水过~
- bzoj2190 [SDOI2008]仪仗队 - 筛法 - 欧拉函数
- cp: omitting directory解决方案
- 时间戳转换成DateTime