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.

hashable的更多相关文章

  1. 实习小记-python中可哈希对象是个啥?what is hashable object in python?

    废话不多说直接祭上python3.3x的文档:(原文链接) object.__hash__(self) Called by built-in function hash() and for opera ...

  2. Swift自定义Class实现Hashable

    假如有个Bit类,其中含有CGPoint类型的point属性,Class定义如下 class Bit { var point : CGPoint init(point : CGPoint) { sel ...

  3. 【转】实习小记-python中可哈希对象是个啥?what is hashable object in python?

    [转]实习小记-python中可哈希对象是个啥?what is hashable object in python? 废话不多说直接祭上python3.3x的文档:(原文链接) object.__ha ...

  4. 什么是可哈希的(hashable)

    如果一个对象在自己的生命周期中有一哈希值(hash value)是不可改变的,那么它就是可哈希的(hashable)的,因为这些数据结构内置了哈希值,每个可哈希的对象都内置了__hash__方法,所以 ...

  5. python hashable

    判断一个对象是否hashable: hash(obj) 或 obj.__hash__() ,返回 hash 值 hashable 的有: int / float / tuple / str/  obj ...

  6. hashable/iterable与orderable

    ################ # hashable协议 # ################ # 一个对象能被称为hashable,它必须实现__hash__与_eq__方法: >>& ...

  7. swift的Hashable

    Conforming to the Hashable Protocol To use your own custom type in a set or as the key type of a dic ...

  8. Python学习笔记 | 关于python数据对象 hashable & unhashable 的理解

    文章目录 写在前面 hashable & unhashable mutable & immutable 实例检测 后续思考 参考文章 写在前面 Hash(哈希.散列)是一个将大体量数据 ...

  9. [python数据结构] hashable, list, tuple, set, frozenset

    学习 cs212 unit4 时遇到了 tuple, list, set 同时使用的问题,并且进行了拼接.合并操作.于是我就被弄混了.所以在这里进行一下总结. hashable and unhasha ...

  10. hashable与unhashable

    不可哈希(unhashable):就是指其可变,如列表.字典等,都能原地进行修改. 可哈希(hashable):不可变,如字符串.元组那样,不能原地修改. 利用set()和{}建立集合时,要求集合中的 ...

随机推荐

  1. 为何ARM linux会引入Device Tree(转)

    http://www.360doc.com/content/14/0522/20/14530056_380011180.shtml

  2. python基础知识09-继承,多继承和魔术方法

    1.继承 class Father: def init(self,age,sex): self.age = age self.sex = sex class Son(Father): 类名后面写括号, ...

  3. HDU 1087 Super Jumping! Jumping! Jumping! (LIS的最大和)

    题意: 给定n个数的序列, 找出最长上升子序列和. 分析: #include<cstdio> #include<iostream> #include<queue> ...

  4. No unique bean of type..... Unsatisfied dependency of type

    比如在XXXServiceImpl里面写了aa()方法给别的地方调用 但是自己又调用了自己 在开头写了 @Autowired Private XXX xxx; xxx.aa(); 这样重复调用自己的b ...

  5. oracle自增序列创建

    表atable(id,a) id需要自增 首先建立一个序列:create sequence seq_atable minvalue 1 maxvalue 999999999999999999 star ...

  6. linux rdesktop远程Win7老是提示密码错误问题解决

    最近使用rdesktop远程Win7老是提示密码错误,输了N次,无比确认密码是正确的. 在Win7系统本身登录也是正常的. 但rdesktop远程就是报密码错误. 开始怀疑更新了最新版本问题,但是使用 ...

  7. 【BZOJ2560】串珠子(状压DP,容斥原理)

    题意: 铭铭有n个十分漂亮的珠子和若干根颜色不同的绳子.现在铭铭想用绳子把所有的珠子连接成一个整体.现在已知所有珠子互不相同,用整数1到n编号.对于第i个珠子和第j个珠子,可以选择不用绳子连接,或者在 ...

  8. hdu4115:Eliminate the Conflict

    n<=10000局剪刀石头布,对面第i局出Ai,m<=10000种对你出什么提出的要求:Xi Yi Wi 表示第Xi局和第Yi局,Wi=1:必须不同:Wi=0:必须相同,问是否存在你一局都 ...

  9. [Bzoj1022][SHOI2008]小约翰的游戏John(博弈论)

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2976  Solved: 1894[Submit] ...

  10. Spring的Web MVC框架

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/web-mvc-framework.html: Spring web MVC框架提供了模型-视图-控 ...