refactor(api)!: drop Timing class; emit signed list[int] from get_raw_timings#17
Closed
balloob wants to merge 2 commits into
Closed
refactor(api)!: drop Timing class; emit signed list[int] from get_raw_timings#17balloob wants to merge 2 commits into
balloob wants to merge 2 commits into
Conversation
`Command.get_raw_timings()` now returns a flat `list[int]` of signed microseconds (positive = mark, negative = space), matching the convention used by ESPHome, IRremoteESP8266, and most Python IR tooling. The `Timing` dataclass is gone. This removes per-pulse dataclass instantiation (34 `Timing` objects per NEC call × 39 commands = 1326 for the bundled LG TV set alone), cleans up the `low_us=0` end-pulse workaround into a single trailing positive int, and lets downstream integrations pass timings straight through instead of flattening pairs at the call site. BREAKING CHANGE: `get_raw_timings()` returns `list[int]` instead of `list[Timing]`. `infrared_protocols.Timing` is removed. Closes #15 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
Timingdataclass with a flatlist[int]return type onCommand.get_raw_timings(), using the signed-microsecond convention (positive = mark, negative = space) shared by ESPHome, IRremoteESP8266, and most Python IR tooling.Closes #15.
Why
Timingallocations per NEC call × 39 commands = 1326 dataclass instances for the bundled LG TV set alone. The new representation stores only ints (small ints are cached).remote_transmitter, IRremoteESP8266sendRaw, LIRC, and Flipper.irall use flat lists; home-assistant/core consumers already flatten pairs on every call.low_us=0smell. The trailing end pulse is now a single positive int instead of a fake-zero pair. See the previousNECCommandatcommands.py:111/:125.rf-protocolsmade the same switch in PR #2 / commit846d351; downstream core PRs (core#168447, core#168448, core#168450) all got shorter.Breaking change
infrared_protocols.Timingis removed.Command.get_raw_timings()returnslist[int](signed µs) instead oflist[Timing].Downstream integrations become:
Draft
Stacked on
flipper-ir-loader. Depends on that branch landing first; target base will move tomainonce the parent merges. Release as 2.0.0 because of the signature break.Test plan
pytest— existingtest_commands.pyrewritten forlist[int], all 18 tests passruff check+ruff format --checklg_infrared,esphome,smlight, andkitchen_sinkconsumers (not yet pushed)