summaryrefslogtreecommitdiff
path: root/docs/examples/userguide/language_basics/parameter_refcount.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/userguide/language_basics/parameter_refcount.pyx')
-rw-r--r--docs/examples/userguide/language_basics/parameter_refcount.pyx3
1 files changed, 3 insertions, 0 deletions
diff --git a/docs/examples/userguide/language_basics/parameter_refcount.pyx b/docs/examples/userguide/language_basics/parameter_refcount.pyx
index 5ffd28c44..6fe3ffadd 100644
--- a/docs/examples/userguide/language_basics/parameter_refcount.pyx
+++ b/docs/examples/userguide/language_basics/parameter_refcount.pyx
@@ -7,14 +7,17 @@ import sys
python_dict = {"abc": 123}
python_dict_refcount = sys.getrefcount(python_dict)
+
cdef owned_reference(object obj):
refcount = sys.getrefcount(python_dict)
print('Inside owned_reference: {refcount}'.format(refcount=refcount))
+
cdef borrowed_reference(PyObject * obj):
refcount = obj.ob_refcnt
print('Inside borrowed_reference: {refcount}'.format(refcount=refcount))
+
print('Initial refcount: {refcount}'.format(refcount=python_dict_refcount))
owned_reference(python_dict)
borrowed_reference(<PyObject *>python_dict)