[Python] Fast concatenation of bytes() in python3

Discussão em 'Python' iniciado por Stack, Agosto 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have an array of byte-strings in python3 (it's an audio chunks). I want to make one big byte-string from it. Simple implementation is kind of slow. How to do it better?

    chunks = []
    while not audio.ends():
    chunks.append( bytes(audio.next_buffer()) )
    do_some_chunk_processing()

    all_audio=b''
    for ch in chunks:
    all_audio += ch


    How to do it faster?

    Continue reading...

Compartilhe esta Página