Learn Before
Code

Reference Counting Example

# Literal 9 is an object b = 9 # Reference count of object 9 # becomes 0. b = 4

In the above example, the value 9 is an object and thus memory is allocated for it to be assigned to variable b. At this point, it has a reference count value of 1. Once the variable b is reassigned to 4, the reference count of value 9 decrements to 0. Hence, 9 is deallocated from memory.

0

1

Updated 2021-06-14

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science