先贴上Python官网中对数据模型描述的几段话。(在python官网的 语言参考>>数据模型 那部分)

Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity.

An object’s type determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. The type() function returns an object’s type (which is an object itself). Like its identity, an object’s type is also unchangeable.

The value of some objects can change. Objects whose value can change are said to be mutable; objects whose value is unchangeable once they are created are called immutable. (The value of an immutable container object that contains a reference to a mutable object can change when the latter’s value is changed; however the container is still considered immutable, because the collection of objects it contains cannot be changed. So, immutability is not strictly the same as having an unchangeable value, it is more subtle.) An object’s mutability is determined by its type; for instance, numbers, strings and tuples are immutable, while dictionaries and lists are mutable.

Some objects contain references to other objects; these are called containers. Examples of containers are tuples, lists and dictionaries. The references are part of a container’s value. In most cases, when we talk about the value of a container, we imply the values, not the identities of the contained objects; however, when we talk about the mutability of a container, only the identities of the immediately contained objects are implied. So, if an immutable container (like a tuple) contains a reference to a mutable object, its value changes if that mutable object is changed.

每个对象有: identity, type, value; 其中 identity 和 type 总是 不可变 的。

对于对象的值来说,有的可变,有的不可变。

例如:numbers, strings and tuples 是 不可变 的; dictionaries and lists 是 可变 的。

有些对象包含其它对象的引用,这些对象叫做容器(containers), 例如 tuples, lists and dictionaries.

这些引用是一个容器的 value 的一部分。通常,我们说到一个容器的 value 的时候,我们暗指的是该容器所包含的对象的 value, 而不是对象的 identities。

然而当我们说到一个容器的可变性的时候,我们暗指的是该容器直接包含的对象的 identity.

因此,如果一个不可变容器(比如 tuple)包含一个到可变对象的引用的时候,如果那个可变对象改变的话它的值就改变了。

以上算是对英文原文的选择性翻译,下面举个栗子:

以为理解了,真要写出来让别人能看懂的时候反倒自己又迷糊了,待加,待加

最新文章

  1. MySQL慢查询Explain Plan分析
  2. css用背景图来替换文字来达到隐藏文字的目的
  3. HTML5初学总结
  4. 菜鸟学SSH(十五)——简单模拟Hibernate实现原理
  5. [转]Multiple outputs from T4 made easy
  6. GCC编译器和GDB调试器常用选项
  7. NOI LINUX装机记
  8. 解决JavaScript中使用$.ajax方式提交数组参数
  9. 实体框架 (EF) 入门 => 六、性能注意事项
  10. [CoffeeScript] Level 4 Arrays, Objects, Iterations -- Ex
  11. sharepreference实现记住password功能
  12. 全互联结构DVPN综合配置示例
  13. Codeforces 56D Changing a String 编辑距离 记忆dp
  14. Oculus关于Internal Error:OVR53225466报错解决方法
  15. Python之面向对象四
  16. 【深度学习】目标检测算法总结(R-CNN、Fast R-CNN、Faster R-CNN、FPN、YOLO、SSD、RetinaNet)
  17. js object数据类型
  18. C# 动态调用WebService 3
  19. 群晖IP地址更新问题
  20. 查询设备的IP地址/掩码/MAC/网关

热门文章

  1. H264关于RTP协议的实现
  2. Selenium2学习-021-WebUI自动化实战实例-019-设置浏览器窗口位置大小
  3. Selenium2学习-011-WebUI自动化实战实例-009-JavaScript 在 Selenium 自动化中的应用实例之一(赋值)
  4. SQL、LINQ、Lambda 三种用法(转)
  5. BIND_MISMATCH导致过多VERSION COUNT的问题
  6. 还原ORACLE DUMP 的值
  7. Metro之Popup控件的使用(登录)
  8. Java 多线程Future和FutureTask
  9. 电量显示Binding Converter MVVM
  10. oracle 常用视图和表