zoukankan      html  css  js  c++  java
  • 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.

     

     

     

     

     

     

     

     

  • 相关阅读:
    矿Mac必备软件
    PHP第六课 使用方法数组
    I/O概述和审查操作
    应用程序配置文件
    他毕业两年,博客一年,时间
    苹果公司的回复
    CImage类的介绍与使用
    数据库移植遇到的问题
    MP算法和OMP算法及其思想
    ROR 环境的 搭建
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9063869.html
Copyright © 2011-2022 走看看