官术网_书友最值得收藏!

Assigning one reference to another

When we assign from one variable to another, what we're really doing is assigning from one object reference to another object reference, so that both references then refer to the same object. For example, let's assign our existing variable x to a new variable y:

>>> y = x

That gives us this resulting reference-object diagram:

Figure 4.3: Assign the existing name 'x' to the name 'y'

Now both references refer to the same object. We now reassign x to another new integer:

>>> x = 3000

Doing this gives us a reference-object diagram showing our two references and our two objects:

Figure 4.4: Assign a new integer 3000 to 'x'

In this case there is no work for the garbage collector to do because all of the objects are reachable from live references.

主站蜘蛛池模板: 高邮市| 扎鲁特旗| 门头沟区| 通化市| 鲁甸县| 正镶白旗| 威信县| 巩留县| 金乡县| 息烽县| 滦南县| 奉化市| 隆回县| 罗田县| 万盛区| 马公市| 长汀县| 自治县| 璧山县| 井研县| 临澧县| 泉州市| 庆安县| 兰西县| 景宁| 云浮市| 全南县| 高淳县| 凯里市| 浙江省| 金川县| 炎陵县| 凉城县| 呈贡县| 缙云县| 黄龙县| 定南县| 沙田区| 郴州市| 酒泉市| 吉安县|