Quick actions

cmd+k|ctrl+k

Navigation

Languages

No Ctypes?

Snippet info

Language

Python

Visibility

public

Author

2cool4gentoo

Created

2024-08-16T07:00:53.998019Z

Updated

2024-08-16T07:35:16.940509Z

import sys
a = [1,2,3]
print(hex(id(a))) 
print(sys.getrefcount(a)) 
import ctypes
def ref_count(address: int):
    return ctypes.c_long.from_address(address).value
print(ref_count(id(a)))
b = a
print(hex(id(b)))
print(ref_count(id(a))) 
b = None
print(id(b))
a_id = id(a)
a = None
print(ref_count(a_id))
print(ref_count(a_id))
INFO