toUByteArray: Returns an array of type UByteArray, which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array.
asUByteArray: Returns an array of type UByteArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array.
Explanation about difference between in copy and view:
While executing the functions, some of them return a copy of the input array, while some return the view. When the contents are physically stored in another location, it is called Copy. If on the other hand, a different view of the same memory content is provided, we call it as View
References:
toUByteArray
asUByteArray
NumPy - Copies & Views