summaryrefslogtreecommitdiff
path: root/doc/source/user/quickstart.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/source/user/quickstart.rst')
-rw-r--r--doc/source/user/quickstart.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst
index 5ef8b145f..262f53c1c 100644
--- a/doc/source/user/quickstart.rst
+++ b/doc/source/user/quickstart.rst
@@ -884,6 +884,17 @@ The ``copy`` method makes a complete copy of the array and its data.
[ 8, 10, 10, 11]])
+Sometimes ``copy`` should be called after slicing if the original array is not required anymore.
+For example, suppose ``a`` is a huge intermediate result and the final result ``b`` only contains
+a small fraction of ``a``, a deep copy should be made when constructing ``b`` with slicing::
+
+ >>> a = np.arange(int(1e8))
+ >>> b = a[:100].copy()
+ >>> del a # the memory of ``a`` can be released.
+
+If ``b = a[:100]`` is used instead, ``a`` is referenced by ``b`` and will persist in memory
+even if ``del a`` is executed.
+
Functions and Methods Overview
------------------------------