Search notes:

Python: sys.getrefcount(obj)

sys.getrefcount(obj) returns the reference counter of the object obj.
Because calling sys.getrefcount(obj) also increases the reference counter of obj for the duration of the call, sys.getrefcount(obj) returns a number that is at least 2.
import sys

class CLS: pass

obj_ref_1 = CLS()

print(sys.getrefcount(obj_ref_1)) # -> 2

obj_ref_2 = obj_ref_1
obj_ref_3 = obj_ref_1

print(sys.getrefcount(obj_ref_1)) # -> 4

obj_ref_1 = CLS()

print(sys.getrefcount(obj_ref_1)) # -> 2
print(sys.getrefcount(obj_ref_2)) # -> 3
Github repository about-Python, path: /standard-library/sys/getrefcount.py

See also

Using ctypes to get an object's reference counter
sys

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758204033, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/sys/getrefcount(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78