dpnp.dpnp_array.dpnp_array.tobytes

method

dpnp_array.tobytes(order='C')[source]

Constructs Python bytes containing the raw data bytes in the array.

For full documentation refer to numpy.ndarray.tobytes.

Parameters:

order ({None, "C", "F", "A", "K"}, optional) --

Controls the memory layout of the bytes object.

Default: "C".

Returns:

out -- Python bytes exhibiting a copy of array's raw data.

Return type:

bytes

See also

dpnp.frombuffer

Construct a 1D array from Python bytes.

Examples

>>> import dpnp as np
>>> x = np.array([[0, 1], [2, 3]], dtype='i2')
>>> x.tobytes()
b'\x00\x00\x01\x00\x02\x00\x03\x00'
>>> x.tobytes("C") == x.tobytes()
True
>>> x.tobytes("F")
b'\x00\x00\x02\x00\x01\x00\x03\x00'