Say you live in a wood framed apartment building and your neighbor to the left has a 2.4 GHz wifi AP running a 20 MHz channel on channel 1, your neighbor to the right has another similarly configured AP on channel 6, and your neighbor directly below you has an AP on channel 11. The other neighbors diagonally to you are on channels 3 and 7. The 2.4 GHz spectrum in your apartment is totally shit because you're seeing everyone else's AP at -68 or thereabouts, because it's a wood framed building and they're so close to you, the spectrum is totally crapped up and noisy but it's not "jamming". This script has the same effect on real world data transfer speeds as the effect in a totally normal major urban area "2.4 GHz is shit here because I live in a 65 unit building and every single suite has their own wifi AP".
What this small script is doing has basically the same effect on a particular section of 20/40 MHz wide radio spectrum as if you were to install any ordinary $70 wifi AP in WPA2-PSK mode, put it on your choice of channel, and leave a pair of laptops associated to it running bidirectional iperf tests on a 1-minute cron job continually between each other. Totally legit. It's just making the channel in question "noisy" RF-wise, because wifi radios are a "listen before transmit" (CSMA) half duplex medium.
Where it gets into a grey area is stuff like this:
http://www.cnn.com/2014/10/03/travel/marriott-fcc-wi-fi-fine...
http://money.cnn.com/2015/01/27/technology/fcc-wifi-hotel/
operating a noisy 2.4 or 5.8 GHz shitty thing on your own AP is totally legal. Connecting to other peoples' networks or gear at a layer 2 ethernet level and issuing deauth frames is not, and the FCC can come down on you for it. The difference is that the first (being noisy) is at basically OSI layer 1, you're shitting on the radio spectrum the same way as if you had a non-ethernet-speaking RF noisy baby monitor, but not talking to anybody else's devices by their MAC address, the second is actually an active form of layer 2 ethernet fabric attack (that happens to be conducted via 802.11abgn(ac))