@@ -12,6 +12,36 @@ The `memoryview()` function creates memory views of bytes-like objects without c
1212| ` bytes(mv) ` conversion | O(n) | O(n) | n = view size; copies data |
1313| Modification | O(1) | O(1) | Only if underlying buffer is mutable (e.g., bytearray) |
1414
15+ ## Methods
16+
17+ | Method | Time | Space | Notes |
18+ | --------| ------| -------| -------|
19+ | ` tobytes() ` | O(n) | O(n) | Convert to bytes object |
20+ | ` tolist() ` | O(n) | O(n) | Convert to list of elements |
21+ | ` toreadonly() ` | O(1) | O(1) | Return read-only version of view |
22+ | ` release() ` | O(1) | O(1) | Release underlying buffer |
23+ | ` cast(format) ` | O(1) | O(1) | Reinterpret as different type; must be same byte size |
24+ | ` hex() ` | O(n) | O(n) | Return hex string representation |
25+ | ` count(value) ` | O(n) | O(1) | Count occurrences of value |
26+ | ` index(value) ` | O(n) | O(1) | Find first index of value; raises ValueError if not found |
27+
28+ ## Attributes
29+
30+ | Attribute | Time | Notes |
31+ | -----------| ------| -------|
32+ | ` obj ` | O(1) | Underlying object the memoryview refers to |
33+ | ` nbytes ` | O(1) | Total bytes in the view |
34+ | ` readonly ` | O(1) | Bool indicating if memory is read-only |
35+ | ` format ` | O(1) | Struct format string (e.g., 'B' for unsigned byte) |
36+ | ` itemsize ` | O(1) | Size in bytes of each element |
37+ | ` ndim ` | O(1) | Number of dimensions |
38+ | ` shape ` | O(1) | Tuple of dimension sizes |
39+ | ` strides ` | O(1) | Tuple of bytes to step in each dimension |
40+ | ` suboffsets ` | O(1) | Tuple for PIL-style arrays; None for simple buffers |
41+ | ` contiguous ` | O(1) | Bool; True if C or Fortran contiguous |
42+ | ` c_contiguous ` | O(1) | Bool; True if C-order contiguous |
43+ | ` f_contiguous ` | O(1) | Bool; True if Fortran-order contiguous |
44+
1545## Basic Usage
1646
1747### From Bytes
0 commit comments