Skip to content

Add __len__ to AudioRing and EventQueue - #11

Open
evzans wants to merge 1 commit into
fufuchiu:mainfrom
evzans:feat-streaming-len-dunder
Open

evzans wants to merge 1 commit into
fufuchiu:mainfrom
evzans:feat-streaming-len-dunder

Conversation

@evzans

@evzans evzans commented Sep 10, 2026

Copy link
Copy Markdown

Both and expose a / property for checking occupancy, but neither implements . This means raises even though the intent is obvious.

This adds the standard dunder to both classes, delegating to the existing internal collections. is the idiomatic Python way to check container size, and having it work makes the streaming primitives feel more like standard library types.

Tests in verify the dunder matches the existing property for both classes across push/pop/append/take operations.

Both classes expose a size/pending property but lack the standard
__len__ dunder. Adding it makes len() work naturally, which is what
most Python code reaches for when checking buffer occupancy.
@evzans
evzans requested a review from fufuchiu as a code owner September 10, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant