Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do objects work?
#2
There is an object in memory containing the value 5. Concretely it is a sequence of bytes in memory and the value 5 is written somewhere in binary form on these bytes. The object receives a unique ID when the memory for this object is allocated. Normally python uses the address in memory as the object's ID, which is an easy way to guarantee that different objects have different IDs. The only thing to know is that once the object has been deallocated, the same address, ID can be reused for another object. Live example:
>>> x = []
>>> id(x)
140240781096328
>>> x = []
>>> id(x)
140240781067400
>>> x = []
>>> id(x)
140240781096328
Reply


Messages In This Thread
How do objects work? - by pyThon_ - Oct-24-2019, 08:56 AM
RE: How do objects work? - by Gribouillis - Oct-24-2019, 09:35 AM
RE: How do objects work? - by jefsummers - Oct-24-2019, 02:01 PM
RE: How do objects work? - by pyThon_ - Oct-24-2019, 03:06 PM
RE: How do objects work? - by snippsat - Oct-24-2019, 03:41 PM
RE: How do objects work? - by pyThon_ - Oct-24-2019, 03:54 PM
RE: How do objects work? - by Gribouillis - Oct-24-2019, 04:16 PM
RE: How do objects work? - by pyThon_ - Oct-24-2019, 06:52 PM
RE: How do objects work? - by snippsat - Oct-24-2019, 04:34 PM
RE: How do objects work? - by Gribouillis - Oct-24-2019, 10:05 PM
RE: How do objects work? - by pyThon_ - Oct-24-2019, 11:13 PM
RE: How do objects work? - by Gribouillis - Oct-25-2019, 06:13 AM
RE: How do objects work? - by jefsummers - Oct-25-2019, 03:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do integer objects work? pyThon_ 2 1,940 Oct-22-2019, 01:36 AM
Last Post: wavic
  Python - Make Json objects to work concurrently through Threads? WeInThis 0 2,652 Sep-22-2017, 11:31 AM
Last Post: WeInThis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020