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. crontab 和 supervisor

    crontab linux系统自带的工具,可以做定时任务,最小间隔是1分钟 配置crontab 命令 如果是以root用户编辑的,那么最后运行也是以root用户运行脚本文件 crontab -e 命令 ...

  2. Django关于SQL注意事项

    执行原生SQL: from django.db import connection, connections cursor = connection.cursor() cursor.execute( ...

  3. maven添加本地jar包到本地仓库

    1 进入jar包所在文件夹,进入cmd命令 2 执行命令 mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -Dartif ...

  4. pwnable.kr uaf之wp

    几乎都想要放弃了,感觉学了好久还是什么都不会,这个题好像很难的样子,有很多知识点需要补充一下: 1.[UAF]分配的内存释放后,指针没有因为内存释放而变为NULL,而是继续指向已经释放的内存.攻击者可 ...

  5. NOI模拟赛(3.15) sequence(序列)

    Description 小A有N个正整数,紧接着,他打算依次在黑板上写下这N个数.对于每一个数,他可以决定将这个数写在当前数列的最左边或最右边.现在他想知道,他写下的数列的可能的最长严格上升子序列(可 ...

  6. 发布tomcate时报A configuration error occurred during startup.please verify the preference field with the prompat:null

    发布tomcate时报A configuration error occurred during startup.please verify the preference field with the ...

  7. jenkins在linux环境搭建需要用到的linux命令

    需要用到的linux命令如下: 服务器jdk1.7/usr/java/jdk1.7.0_80 jdk1.8/home/hujb/javaJDK/jdk1.8.0_171保存文件时用 : w ! sud ...

  8. [Go]程序实体

    Go语言中的程序实体包括变量.常量.函数.结构体.接口 1.常见声明变量的方式 package main import ( "flag" "fmt" ) fun ...

  9. Linux 修改主机名

    1 vi /etc/sysconfig/network 2 vi /etc/hosts 3 hostname xxx 4 Done! 退出重连后生效

  10. codeforces 315B

    #include<stdio.h> int main() { int n,k,i,flag=0; while(scanf("%d%d",&n,&k)!= ...