magigo / data_science_tool_book_code

9 stars 5 forks source link

Internal numbers of objects are not same by id() as the book showed #3

Closed aisharing closed 6 years ago

aisharing commented 6 years ago

dollar_rate=USD_to_CNY=6.631 id(6.631) 42354128L id(USD_to_CNY) 42354152L id(dollar_rate) 42354152L

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

aisharing commented 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

aisharing commented 6 years ago

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,

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)