From ab3fee9aaa1ff624cddd1e60e8783a332f9661ba Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 13 Jun 2026 12:37:09 +0000 Subject: [PATCH] Optimize sine wave generation with NumPy vectorization Co-authored-by: ManupaKDU <95234271+ManupaKDU@users.noreply.github.com> --- Learning/Part-1/Python/assignment1.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Learning/Part-1/Python/assignment1.py b/Learning/Part-1/Python/assignment1.py index 8f388aa..b058a17 100644 --- a/Learning/Part-1/Python/assignment1.py +++ b/Learning/Part-1/Python/assignment1.py @@ -7,10 +7,8 @@ sampling_rate = 48000.0 amplitude = 16000 file = "test.wav" -sine_wave = [] -for x in range(num_samples): - val = np.sin(2 * np.pi * frequency * x/sampling_rate) - sine_wave.append(val) +x = np.arange(num_samples) +sine_wave = np.sin(2 * np.pi * frequency * x / sampling_rate) nframes=num_samples comptype="NONE" compname="not compressed"