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.
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.
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 โบ stable โบ reference โบ generated โบ numpy.copy.html
numpy.copy โ NumPy v2.5 Manual
Return an array copy of the given object.
NumPy
numpy.org โบ doc โบ 2.0 โบ reference โบ generated โบ numpy.ndarray.copy.html
numpy.ndarray.copy โ NumPy v2.0 Manual
To ensure all elements within an object array are copied, use copy.deepcopy:
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 ...
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.copy.html
numpy.copy โ NumPy v2.2 Manual
Return an array copy of the given object.
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 โบ 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 - >>> import numpy as np >>> x = np.array([[1,2,3],[4,5,6]], order='F') ... For arrays containing Python objects (e.g. dtype=np.object_), the copy is a shallow one.
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.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 โบ python โบ how-to-copy-numpy-array-into-another-array
How to Copy NumPy array into another array? - GeeksforGeeks
July 15, 2025 - In the below example, the given Numpy array 'org_array' is copied to another array 'copy_array' using np.copy () function.