diff options
author | Ma Lin <animalize@users.noreply.github.com> | 2022-05-03 14:41:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 14:41:45 (GMT) |
commit | 1699128c4891da3bbe23553d709261d88855b93f (patch) | |
tree | 5d1a296dec207882dbef227b36834cc177e7a599 /Lib/multiprocessing | |
parent | 9dc4aae8e92cef0590b1130bd5d1c07c1b932b73 (diff) | |
download | cpython-1699128c4891da3bbe23553d709261d88855b93f.zip cpython-1699128c4891da3bbe23553d709261d88855b93f.tar.gz cpython-1699128c4891da3bbe23553d709261d88855b93f.tar.bz2 |
GH-91355: micro-optimize Connection.send_bytes() method (gh-32247)
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/connection.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 1cca66d..65303d2 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -188,10 +188,9 @@ class _ConnectionBase: self._check_closed() self._check_writable() m = memoryview(buf) - # HACK for byte-indexing of non-bytewise buffers (e.g. array.array) if m.itemsize > 1: - m = memoryview(bytes(m)) - n = len(m) + m = m.cast('B') + n = m.nbytes if offset < 0: raise ValueError("offset is negative") if n < offset: |