跳转至

尚未翻译

本页面尚未翻译成中文,因此显示英文原文。 帮助翻译

chunk Module

⚠️ REMOVED IN PYTHON 3.13: The chunk module was deprecated in Python 3.11 and removed in Python 3.13.

The chunk module provides support for reading IFF (Interchange File Format) chunks used by audio files (AIFF, WAV).

Complexity Reference

Operation Time Space Notes
Read chunk O(1) O(1) Header read
Parse chunks O(n) O(n) n = chunk count

Reading IFF Chunks

Parsing Chunk Structure

import chunk

# Open chunk - O(1)
with open('audio.aiff', 'rb') as f:
    chk = chunk.Chunk(f)

    # Read chunk header - O(1)
    chunktype = chk.getname()
    chunksize = chk.getsize()

    # Process chunk data - O(n)
    data = chk.read()

    # Skip to next - O(1)
    chk.skip()