[pypy-issue] Issue #1975: Pydub module very slow compared to CPython implementation (pypy/pypy)
cryzed
issues-reply at bitbucket.org
Tue Feb 10 18:27:20 CET 2015
New issue 1975: Pydub module very slow compared to CPython implementation
https://bitbucket.org/pypy/pypy/issue/1975/pydub-module-very-slow-compared-to-cpython
cryzed:
The Pydub module is 5~ times (PyPy 2) and up to 17~ times (PyPy 3) slower compared to the CPython 3 implementation when using the Pydub module. Absolute values were 3.5~ seconds for CPython, 18~ seconds for PyPy 2 and 58~ seconds for PyPy 3. Here is a sample test case:
```
#!python
import sys
import time
import pydub
PATHS = [
'path_to_audio1.wav',
'path_to_audio2.wav',
'path_to_audio3.wav'
]
def main(duration):
segments = tuple(pydub.AudioSegment.from_file(path) for path in PATHS)
# Create a silent audio segment to easily overlay the other segments
composition = pydub.AudioSegment.silent(duration)
for segment in segments:
position = 0
length = len(segment)
while position < duration:
composition = composition.overlay(segment, position)
position += length
composition.export('output.wav', format='wav')
if __name__ == '__main__':
start = time.time()
main(int(sys.argv[1]))
print(time.time() - start)
```
I use 20 short (~20 seconds) *.ogg audio files for the PATHS and pass in a duration of 60000 milliseconds. Using this script and CPython 3 and PyPy 3 the values were 6~ seconds for CPython 3 and 166 seconds for PyPy 3.
More information about the pypy-issue
mailing list