For later use, you should look for numpy.
This allows for example broadcasting.
I see often, that people are using this libraries,
but they don't know how they can do this without this library.
The benefit of numpy is, that it's implementation is in C and highly optimized.
But for small lists it's ok to use a normal list comprehension or if you want to save memory, a generator expression.
This allows for example broadcasting.
import numpy as np def gen_signal(): amplification = 10.5 time_base = np.linspace(0, np.pi * 2, 1_000_000) signal = np.sin(time_base * 1440) # 1440 Hz signal += np.sin(time_base * 440) # 440 Hz signal += np.sin(time_base * 20) # 20 Hz signal += np.sin(time_base * 44) # 44 Hz signal *= amplification return signalBut you should also know the Python primitives.
I see often, that people are using this libraries,
but they don't know how they can do this without this library.
The benefit of numpy is, that it's implementation is in C and highly optimized.
But for small lists it's ok to use a normal list comprehension or if you want to save memory, a generator expression.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!