Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
4fee35a3
Commit
4fee35a3
authored
7 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
docs/glossary: Describe the callee-owned tuple concept.
parent
bb047558
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/library/uselect.rst
+2
-2
2 additions, 2 deletions
docs/library/uselect.rst
docs/reference/glossary.rst
+23
-0
23 additions, 0 deletions
docs/reference/glossary.rst
with
25 additions
and
2 deletions
docs/library/uselect.rst
+
2
−
2
View file @
4fee35a3
...
@@ -78,8 +78,8 @@ Methods
...
@@ -78,8 +78,8 @@ Methods
.. method:: poll.ipoll(timeout=-1, flags=0)
.. method:: poll.ipoll(timeout=-1, flags=0)
Like :meth:`poll.poll`, but instead returns an iterator which yields
Like :meth:`poll.poll`, but instead returns an iterator which yields
a
`callee-owned tuple
s
`. This function provides efficient, allocation-free
`callee-owned tuple`. This function provides
an
efficient, allocation-free
way to poll on streams.
way to poll on streams.
If *flags* is 1, one-shot behavior for events is employed: streams for
If *flags* is 1, one-shot behavior for events is employed: streams for
...
...
This diff is collapsed.
Click to expand it.
docs/reference/glossary.rst
+
23
−
0
View file @
4fee35a3
...
@@ -15,6 +15,29 @@ Glossary
...
@@ -15,6 +15,29 @@ Glossary
may also refer to "boardless" ports like
may also refer to "boardless" ports like
:term:`Unix port <MicroPython Unix port>`).
:term:`Unix port <MicroPython Unix port>`).
callee-owned tuple
A tuple returned by some builtin function/method, containing data
which is valid for a limited time, usually until next call to the
same function (or a group of related functions). After next call,
data in the tuple may be changed. This leads to the following
restriction on the usage of callee-owned tuples - references to
them cannot be stored. The only valid operation is extracting
values from them (including making a copy). Callee-owned tuples
is a MicroPython-specific construct (not available in the general
Python language), introduced for memory allocation optimization.
The idea is that callee-owned tuple is allocated once and stored
on the callee side. Subsequent calls don't require allocation,
allowing to return multiple values when allocation is not possible
(e.g. in interrupt context) or not desirable (because allocation
inherently leads to memory fragmentation). Note that callee-owned
tuples are effectively mutable tuples, making an exception to
Python's rule that tuples are immutable. (It may be interesting
why tuples were used for such a purpose then, instead of mutable
lists - the reason for that is that lists are mutable from user
application side too, so a user could do things to a callee-owned
list which the callee doesn't expect and could lead to problems;
a tuple is protected from this.)
CPython
CPython
CPython is the reference implementation of Python programming
CPython is the reference implementation of Python programming
language, and the most well-known one, which most of the people
language, and the most well-known one, which most of the people
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment