From 21073ffabed5ce2f676dbbcd5dde41c2933e9be4 2020-02-01 19:05:11 From: Jonas Haag Date: 2020-02-01 19:05:11 Subject: [PATCH] Speedup _make_wav When numpy is installed, ~30x speedup; otherwise, ~5x speedup --- diff --git a/IPython/lib/display.py b/IPython/lib/display.py index e7c427c..de31788 100644 --- a/IPython/lib/display.py +++ b/IPython/lib/display.py @@ -130,7 +130,6 @@ class Audio(DisplayObject): @staticmethod def _make_wav(data, rate, normalize): """ Transform a numpy array to a PCM bytestring """ - import struct from io import BytesIO import wave @@ -145,7 +144,7 @@ class Audio(DisplayObject): waveobj.setframerate(rate) waveobj.setsampwidth(2) waveobj.setcomptype('NONE','NONE') - waveobj.writeframes(b''.join([struct.pack('