Why is the id of a Python class not unique when called quickly?

前端 未结 6 1162
花落未央
花落未央 2020-11-22 15:29

I\'m doing some things in Python (3.3.3), and I came across something that is confusing me since to my understanding classes get a new id each time they are called.

6条回答
  •  醉话见心
    2020-11-22 16:12

    A example where the memory location (and id) is not released is:

    print([someClass() for i in range(10)])
    

    Now the ids are all unique.

提交回复
热议问题