https://github.com/python/cpython/commit/9dbf77beb62c65e18eb766f0e867b7d96fa7b56a
commit: 9dbf77beb62c65e18eb766f0e867b7d96fa7b56a
branch: main
author: Cody Maloney <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-11-26T21:15:12+05:30
summary:

gh-141968: use `bytearray.take_bytes` in `wave._byteswap` (#141973)

files:
A Misc/NEWS.d/next/Library/2025-11-25-23-22-46.gh-issue-141968.R1sHnJ.rst
M Lib/wave.py

diff --git a/Lib/wave.py b/Lib/wave.py
index 056bd6aab7ffa3..25ca9ef168e8a5 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -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
index 00000000000000..16b9ad78c3cd3f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-11-25-23-22-46.gh-issue-141968.R1sHnJ.rst
@@ -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`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to