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. 上海苹果维修点分享苹果电脑MACBOOK故障维修常见案例

    苹果的电子设备无论是外观和性能都是无与伦比的美丽,很多开发者都开始选用苹果电脑macbook.近年来苹果售后维修点来维修苹果电脑的用户也越来越多,我们上海苹果维修点就整理分享了一些苹果电脑MACBOO ...

  2. MySQL 初识

    一.MySQL介绍: MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,M ...

  3. laravel(4.2) +Zizaco

    操作步骤:https://github.com/Zizaco/entrust/tree/1.0 这篇博客说的蛮详细的:http://blog.boolw.com/?p=241 简化后的步骤 1.在根项 ...

  4. 2016年工作中遇到的问题41-50:Dubbo注册中心奇葩问题,wifi热点坑了

    41.获得JSON中的变量.//显示json串中的某个变量,name是变量名function json(json,name){ var jsonObj = eval(json); return jso ...

  5. Spring拓展接口之BeanPostProcessor,我们来看看它的底层实现

    前言 开心一刻 小明:“妈,我被公司开除了”,妈:“啊,为什么呀?”, 小明:“我骂董事长是笨蛋,公司召开高层会议还要起诉我”,妈:“告你诽谤是吧?”,小明:“不是,他们说要告我泄露公司机密” Bea ...

  6. BeautifulSoup4系列二

    前言 本篇详细介绍beautifulsoup4的功能,从最基础的开始讲起,让小伙伴们都能入门 一.读取HTML页面 1.先写一个简单的html页面,把以下内容copy出来,保存为html格式文件 &l ...

  7. 安装mysql后无法找到临时密码的解决方案

    安装mysql后无法找到临时密码的解决方案 一.环境 系统:CentOS7mysql:5.7.20 二.解决步骤 step1:修改/etc/my.cnf添加: skip-grant-tables   ...

  8. 【板+背包】多重背包 HDU Coins

    http://acm.hdu.edu.cn/showproblem.php?pid=2844 [题意] 给定n种价值为Ci,个数为Wi的硬币,问在1~V中的这些数中哪些数能由这些硬币组成? [思路] ...

  9. Java 实体-实体的映射框架

    一.Object mapping 的技术分类: 运行期 反射调用set/get 或者是直接对成员变量赋值 . 该方式通过invoke执行赋值 *,实现时一般会采用beanutil, Javassist ...

  10. hdu4405:Aeroplane chess

    题目大意:有编号为0-n的格子,从0开始,扔骰子扔到几就走几格.有m个瞬移点,每个点可以从格x直接飞到格y,若瞬移到另一个瞬移点可以继续瞬移.求到达格n的期望扔骰子次数. 题解:期望DP入门好题.网上 ...