Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
3720a570
Commit
3720a570
authored
Aug 27, 2021
by
Peter Hinch
Committed by
Damien George
Aug 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs/reference: Mention that slicing a memoryview causes allocation.
parent
4954290e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
docs/reference/speed_python.rst
docs/reference/speed_python.rst
+5
-3
No files found.
docs/reference/speed_python.rst
View file @
3720a570
...
...
@@ -91,9 +91,11 @@ code these should be pre-allocated and passed as arguments or as bound objects.
When passing slices of objects such as `bytearray` instances, Python creates
a copy which involves allocation of the size proportional to the size of slice.
This can be alleviated using a `memoryview` object. `memoryview` itself
is allocated on heap, but is a small, fixed-size object, regardless of the size
of slice it points too.
This can be alleviated using a `memoryview` object. The `memoryview` itself
is allocated on the heap, but is a small, fixed-size object, regardless of the size
of slice it points too. Slicing a `memoryview` creates a new `memoryview`, so this
cannot be done in an interrupt service routine. Further, the slice syntax ``a:b``
causes further allocation by instantiating a ``slice(a, b)`` object.
.. code:: python
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment