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`.