File tree 3 files changed +67
-2
lines changed
3 files changed +67
-2
lines changed Original file line number Diff line number Diff line change
1
+ .. _bytes-ops :
2
+
3
+ Native bytes operations
4
+ ========================
5
+
6
+ These ``bytes `` operations have fast, optimized implementations. Other
7
+ bytes operations use generic implementations that are often slower.
8
+
9
+ Construction
10
+ ------------
11
+
12
+ * Bytes literal
13
+ * ``bytes(x: list) ``
14
+
15
+ Operators
16
+ ---------
17
+
18
+ * Concatenation (``b1 + b2 ``)
19
+ * Indexing (``b[n] ``)
20
+ * Slicing (``b[n:m] ``, ``b[n:] ``, ``b[:m] ``)
21
+ * Comparisons (``== ``, ``!= ``)
22
+
23
+ .. _bytes-methods :
24
+
25
+ Methods
26
+ -------
27
+
28
+ * ``b.decode() ``
29
+ * ``b.decode(encoding: str) ``
30
+ * ``b.decode(encoding: str, errors: str) ``
31
+ * ``b.join(x: Iterable) ``
32
+
33
+ .. note ::
34
+
35
+ :ref: `str.encode() <str-methods >` is also optimized.
36
+
37
+ Formatting
38
+ ----------
39
+
40
+ A subset of % formatting operations are optimized (``b"..." % (...) ``).
41
+
42
+ Functions
43
+ ---------
44
+
45
+ * ``len(b: bytes) ``
46
+ * ``ord(b: bytes) ``
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ generate fast code.
36
36
bool_operations
37
37
float_operations
38
38
str_operations
39
+ bytes_operations
39
40
list_operations
40
41
dict_operations
41
42
set_operations
Original file line number Diff line number Diff line change @@ -22,9 +22,14 @@ Operators
22
22
* Comparisons (``== ``, ``!= ``)
23
23
* Augmented assignment (``s1 += s2 ``)
24
24
25
+ .. _str-methods :
26
+
25
27
Methods
26
28
-------
27
29
30
+ * ``s.encode() ``
31
+ * ``s.encode(encoding: str) ``
32
+ * ``s.encode(encoding: str, errors: str) ``
28
33
* ``s1.endswith(s2: str) ``
29
34
* ``s.join(x: Iterable) ``
30
35
* ``s.replace(old: str, new: str) ``
@@ -34,8 +39,21 @@ Methods
34
39
* ``s.split(sep: str, maxsplit: int) ``
35
40
* ``s1.startswith(s2: str) ``
36
41
42
+ .. note ::
43
+
44
+ :ref: `bytes.decode() <bytes-methods >` is also optimized.
45
+
46
+ Formatting
47
+ ----------
48
+
49
+ A subset of these common string formatting expressions are optimized:
50
+
51
+ * F-strings
52
+ * ``"...".format(...) ``
53
+ * ``"..." % (...) ``
54
+
37
55
Functions
38
56
---------
39
57
40
- * ``len(s: str) ``
41
- * ``ord(s: str) ``
58
+ * ``len(s: str) ``
59
+ * ``ord(s: str) ``
You can’t perform that action at this time.
0 commit comments