File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ See also :ref:`Remove functions <remove-funcs>`.
15
15
Borrowed references
16
16
===================
17
17
18
+ A borrowed reference is a pointer which doesn't "hold" a reference. If the
19
+ object is destroyed, the borrowed reference becomes a dangling pointer: pointer
20
+ pointing to freed memory which might be reused by a new object.
21
+
22
+ Borrowed references can lead to bugs and crashes when misused. The
23
+ :ref: `Specialized list for small integers <specialized-list >` optimization is
24
+ incompatible with borrowed references, since the runtime cannot guess when the
25
+ temporary object should be destroyed.
26
+
18
27
CPython 3.7 has many functions and macros which return or use borrowed
19
28
references. For example, ``PyTuple_GetItem() `` returns a borrowed reference,
20
29
whereas ``PyTuple_SetItem() `` stores a borrowed reference (store an item into a
Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ PyPy experimented Software Transactional Memory (STM) but the project has
110
110
been abandoned, `PyPy STM <http://doc.pypy.org/en/latest/stm.html >`_.
111
111
112
112
113
+ .. _specialized-list :
114
+
113
115
Specialized list for small integers
114
116
===================================
115
117
You can’t perform that action at this time.
0 commit comments