summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMa Lin <animalize@users.noreply.github.com>2022-05-03 14:41:45 (GMT)
committerGitHub <noreply@github.com>2022-05-03 14:41:45 (GMT)
commit1699128c4891da3bbe23553d709261d88855b93f (patch)
tree5d1a296dec207882dbef227b36834cc177e7a599 /Lib
parent9dc4aae8e92cef0590b1130bd5d1c07c1b932b73 (diff)
downloadcpython-1699128c4891da3bbe23553d709261d88855b93f.zip
cpython-1699128c4891da3bbe23553d709261d88855b93f.tar.gz
cpython-1699128c4891da3bbe23553d709261d88855b93f.tar.bz2
GH-91355: micro-optimize Connection.send_bytes() method (gh-32247)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/connection.py5
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: