summaryrefslogtreecommitdiffstatshomepage
path: root/docs/reference/speed_python.rst
diff options
context:
space:
mode:
authorPeter Hinch <peter@hinch.me.uk>2021-08-27 17:45:13 +0100
committerDamien George <damien@micropython.org>2021-08-30 23:55:29 +1000
commit3720a570f2c2d1617d59a9832e4384e4479006a7 (patch)
tree0ab681f9c2efc290e716bb4291f8d45a92cd4f70 /docs/reference/speed_python.rst
parent4954290e8675d67e8925708230f7a23664ec4b05 (diff)
downloadmicropython-3720a570f2c2d1617d59a9832e4384e4479006a7.tar.gz
micropython-3720a570f2c2d1617d59a9832e4384e4479006a7.zip
docs/reference: Mention that slicing a memoryview causes allocation.
Diffstat (limited to 'docs/reference/speed_python.rst')
-rw-r--r--docs/reference/speed_python.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/reference/speed_python.rst b/docs/reference/speed_python.rst
index a563b2d36c..85e956e8e6 100644
--- a/docs/reference/speed_python.rst
+++ b/docs/reference/speed_python.rst
@@ -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