]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141968: use `bytearray.take_bytes` in `wave._byteswap` (#141973)
authorCody Maloney <cmaloney@users.noreply.github.com>
Wed, 26 Nov 2025 15:45:12 +0000 (07:45 -0800)
committerGitHub <noreply@github.com>
Wed, 26 Nov 2025 15:45:12 +0000 (21:15 +0530)
Lib/wave.py
Misc/NEWS.d/next/Library/2025-11-25-23-22-46.gh-issue-141968.R1sHnJ.rst [new file with mode: 0644]

index 056bd6aab7ffa3c3220554eaae9bbe3631afa24d..25ca9ef168e8a539256ec4326bb7b0425690a565 100644 (file)
@@ -97,7 +97,7 @@ def _byteswap(data, width):
         for j in range(width):
             swapped_data[i + width - 1 - j] = data[i + j]
 
-    return bytes(swapped_data)
+    return swapped_data.take_bytes()
 
 
 class _Chunk:
diff --git a/Misc/NEWS.d/next/Library/2025-11-25-23-22-46.gh-issue-141968.R1sHnJ.rst b/Misc/NEWS.d/next/Library/2025-11-25-23-22-46.gh-issue-141968.R1sHnJ.rst
new file mode 100644 (file)
index 0000000..16b9ad7
--- /dev/null
@@ -0,0 +1,2 @@
+Remove data copy from :func:`wave.Wave_read.readframes` and
+:func:`wave.Wave_write.writeframes` by using :func:`bytearray.take_bytes`.