Closed aisharing closed 6 years ago
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM D64)] on win32
I think this issue could be closed now, as I found the reason why this happened. The final internal numbers of the variable depend on the types of the object numbers they are assigned,
if the number which is assigned to variable is integer number, the result will be like the book showed - the variables will be assigned the same internal numbers as the integer number:
id(7) 93874755162328 usd_to_cny=7 id(usd_to_cny) 93874755162328 dollar_rate=7 id(dollar_rate) 93874755162328 dollar_rate=usd_to_cny=7 id(7) 93874755162328 id(dollar_rate) 93874755162328 id(usd_to_cny) 93874755162328
if the number which is assigned to variable is fractional number, the result will NOT be like the book showed - the variables will be assigned the internal numbers as the fractional number, at the same time, the fractional number will get another internal number:
id(6.188) 93874755233432 usd_to_cny=6.188 id(6.188) 93874755233456 id(usd_to_cny) 93874755233432 dollar_rate=6.188 id(6.188) 93874755233480 id(dollar_rate) 93874755233456 dollar_rate=usd_to_cny=6.188 id(6.188) 93874755233432 id(dollar_rate) 93874755233480 id(usd_to_cny) 93874755233480
Another found while I doing the test is: I found all the fractional numbers are using the same internal numbers:
id(6.639) 93874755233456 id(6.63) 93874755233456 id(6.6) 93874755233456 id(6.0) 93874755233456 id(6) 93874755162352 id(5.5) 93874755233456 id(5.1)
Python version: Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM D64)] on win32