@@ -15,6 +15,29 @@ Glossary
1515 may also refer to "boardless" ports like
1616 :term: `Unix port <MicroPython Unix port> `).
1717
18+ callee-owned tuple
19+ A tuple returned by some builtin function/method, containing data
20+ which is valid for a limited time, usually until next call to the
21+ same function (or a group of related functions). After next call,
22+ data in the tuple may be changed. This leads to the following
23+ restriction on the usage of callee-owned tuples - references to
24+ them cannot be stored. The only valid operation is extracting
25+ values from them (including making a copy). Callee-owned tuples
26+ is a MicroPython-specific construct (not available in the general
27+ Python language), introduced for memory allocation optimization.
28+ The idea is that callee-owned tuple is allocated once and stored
29+ on the callee side. Subsequent calls don't require allocation,
30+ allowing to return multiple values when allocation is not possible
31+ (e.g. in interrupt context) or not desirable (because allocation
32+ inherently leads to memory fragmentation). Note that callee-owned
33+ tuples are effectively mutable tuples, making an exception to
34+ Python's rule that tuples are immutable. (It may be interesting
35+ why tuples were used for such a purpose then, instead of mutable
36+ lists - the reason for that is that lists are mutable from user
37+ application side too, so a user could do things to a callee-owned
38+ list which the callee doesn't expect and could lead to problems;
39+ a tuple is protected from this.)
40+
1841 CPython
1942 CPython is the reference implementation of Python programming
2043 language, and the most well-known one, which most of the people
0 commit comments