Open
Conversation
Introduces a read optimization pipeline that merges scattered read requests into contiguous blocks and packs them into minimal PDU exchanges, reducing round-trips when reading multiple variables. - snap7/optimizer.py: Pure-logic optimization with sort, merge, packetize, and extract_results functions - snap7/s7protocol.py: build_multi_read_request and extract_multi_read_data methods for multi-item S7 READ_AREA PDUs - snap7/server/__init__.py: Server-side multi-item read support - snap7/client.py: read_multi_vars now uses optimizer for 2+ dict items, with plan caching for repeated layouts - tests/test_optimizer.py: 23 tests covering unit and integration scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sues - Fix cache mutation bug: deep-copy cached ReadPackets before assigning buffers so repeated calls don't corrupt cached state - Remove dead _map_area_int method - Replace per-call set comprehension with module-level _VALID_AREA_VALUES frozenset for Area validation - Fix O(n^2) byte concatenation in build_multi_read_request using list and b"".join() - Clear optimizer cache on disconnect - Add use_optimizer attribute (default True) to allow opting out Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1895d86 to
0f3790c
Compare
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
snap7/optimizer.py) that merges scatteredread_multi_vars()requests into contiguous blocks and packs them into minimal PDU-sized S7 exchangesread_multi_vars()with 2+ dict items now automatically optimizes: adjacent reads are merged (configurable gap tolerance viaclient.multi_read_max_gap), and the optimization plan is cached for repeated layoutsTest plan
🤖 Generated with Claude Code