Open
Description
These operations related to bytes
values are either common or "fundamental" and worth dedicated primitives if they help with performance:
- + (concatenation)
-
len(b)
-
b[n]
(indexing) -
==
,!=
([mypyc] Implement bytes equality optimizations python/mypy#10928) -
<
,<=
, etc. -
b[:n]
etc. (slicing) ([mypyc] Add primitive for bytes slicing python/mypy#10966) -
s.encode(<literal>)
(forutf8
,ascii
andlatin1
) -
s.encode(x)
(for an arbitrary encoding) -
b.decode(<literal>)
(forutf8
,ascii
andlatin1
) -
b.decode(x)
(for an arbitrary encoding) -
%
formatting- Minimal basic support
- More general
-
b.join(...)
-
b.split(...)
These operations in six
are also quite common in many codebases:
-
ensure_str
-
ensure_binary
These are somewhat common and fairly easy to implement:
-
b.startswith(...)
-
b.endswith(...)
-
b.lower()
-
b.upper()
-
b.strip()
Maybe also support these (fundamental but not very common operations):
-
bytes([n])
(corresponds tochr(x)
) -
ord(b)
-
b * n
This is part of the wider issue #644.