I believe
a = numpy.empty_like(b)
a[:] = b
will copy the values quickly. As Funsi mentions, recent versions of numpy also have the copyto function.
W3Schools
w3schools.com βΊ python βΊ numpy βΊ numpy_copy_vs_view.asp
NumPy Array Copy vs View
The main difference between a copy and a view of an array is that the copy is a new array, and the view is just a view of the original array. The copy owns the data and any changes made to the copy will not affect original array, and any changes made to the original array will not affect the copy.
NumPy
numpy.org βΊ doc βΊ stable βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.5 Manual
Return an array copy of the given object.
09:08
Python NumPy Tutorial 8 - Copy vs View in NumPy Array - YouTube
08:16
NumPy Array Copy vs View | Copy and View in NumPy Array - YouTube
06:35
Numpy Array Copy Vs View - Numpy For Machine Learning 4 - YouTube
05:20
NumPy Deep Copies with copy() | Create Independent Arrays | Python ...
05:49
Numpy Copy and View | View vs Copy in Numpy | Numpy Tutorial for ...
05:53
NumPy Copy vs View
NumPy
numpy.org βΊ doc βΊ 2.0 βΊ reference βΊ generated βΊ numpy.ndarray.copy.html
numpy.ndarray.copy β NumPy v2.0 Manual
Return a copy of the array. ... Controls the memory layout of the copy. βCβ means C-order, βFβ means F-order, βAβ means βFβ if a is Fortran contiguous, βCβ otherwise. βKβ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)
NumPy
numpy.org βΊ doc βΊ 2.3 βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.3 Manual
Return an array copy of the given object.
AskPython
askpython.com βΊ python-modules βΊ numpy βΊ copy-a-numpy-array-into-another-array
How To Copy a Numpy Array Into Another Array? - AskPython
May 4, 2026 - One thing to watch: np.empty_like() does not guarantee that the allocated memory is zeroed out. The array contains whatever bits were already in that memory location. Always explicitly copy data into it before using the array values for anything. Array slicing in NumPy returns a view, not a copy.
NumPy
numpy.org βΊ doc βΊ 2.2 βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.2 Manual
Return an array copy of the given object.
Codecademy
codecademy.com βΊ docs βΊ python:numpy βΊ ndarray βΊ .copy()
Python:NumPy | ndarray | .copy() | Codecademy
October 31, 2025 - The .copy() method in NumPy creates a new, independent copy of an array (ndarray). Unlike simple assignment, which creates a view that shares the same underlying data, it ensures that changes to the new array do not affect the original, and ...
Top answer 1 of 8
96
I believe
a = numpy.empty_like(b)
a[:] = b
will copy the values quickly. As Funsi mentions, recent versions of numpy also have the copyto function.
2 of 8
31
NumPy version 1.7 has the numpy.copyto function that does what you are looking for:
numpy.copyto(dst, src)
Copies values from one array to another, broadcasting as necessary.
See: https://docs.scipy.org/doc/numpy/reference/generated/numpy.copyto.html
Python Examples
pythonexamples.org βΊ python-numpy-duplicate-copy-array
Python Numpy - Duplicate or Copy Array Data to Another Array
The array arr is initialized as a 3D numpy array with shape (2, 2, 2). We create a copy of arr using the copy() function and assign it to arr_copy.
NumPy
numpy.org βΊ doc βΊ 2.1 βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.1 Manual
Return an array copy of the given object.
NumPy
numpy.org βΊ doc βΊ stable βΊ reference βΊ generated βΊ numpy.copyto.html
numpy.copyto β NumPy v2.5 Manual
A boolean array which is broadcasted to match the dimensions of dst, and selects elements to copy from src to dst wherever it contains the value True. ... Try it in your browser! >>> import numpy as np >>> A = np.array([4, 5, 6]) >>> B = [1, 2, 3] >>> np.copyto(A, B) >>> A array([1, 2, 3])
NumPy
numpy.org βΊ doc βΊ 2.0 βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.0 Manual
Return an array copy of the given object.
NumPy
numpy.org βΊ doc βΊ stable βΊ reference βΊ generated βΊ numpy.ndarray.copy.html
numpy.ndarray.copy β NumPy v2.5 Manual
January 31, 2021 - Return a copy of the array. ... Controls the memory layout of the copy. βCβ means C-order, βFβ means F-order, βAβ means βFβ if a is Fortran contiguous, βCβ otherwise. βKβ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)
NumPy
numpy.org βΊ devdocs βΊ reference βΊ generated βΊ numpy.copy.html
numpy.copy β NumPy v2.6.dev0 Manual
Return an array copy of the given object.
NumPy
numpy.org βΊ doc βΊ 2.2 βΊ reference βΊ generated βΊ numpy.ndarray.copy.html
numpy.ndarray.copy β NumPy v2.2 Manual
Return a copy of the array. ... Controls the memory layout of the copy. βCβ means C-order, βFβ means F-order, βAβ means βFβ if a is Fortran contiguous, βCβ otherwise. βKβ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)
GeeksforGeeks
geeksforgeeks.org βΊ how-to-copy-numpy-array-into-another-array
How to Copy NumPy array into another array? - GeeksforGeeks
January 10, 2024 - Original array: [ 1.54 2.99 3.42 4.87 6.94 8.21 7.65 10.5 77.5 ] Copied array: [ 1.54 2.99 3.42 4.87 6.94 8.21 7.65 10.5 77.5 ] In this example, the given 2-D Numpy array 'org_array' is copied to another array 'copy_array' using np.copy () function.