-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pingmessage: performance improvements #110
Conversation
Helps with #101 (although Python's I/O can't really ever be completely as fast as compiled code). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks ok to me, I would just recommend to break the commit in multiple commits since there is a couple of things that are changing to improve performance, but they are not totally clear.
An example of commit organization:
- Change sum algorithm to built-in function
- Use
__slots__
declaration to improve access speed- Reason, why, when and etc
- Break parser logic into a callback dictionary
- Reason, why and etc
- Change comparison from
is
to==
since...
ping @Williangalvani
Reduces memory overhead (no internal __dict__), and improves variable access speeds.
…ple of callbacks Swaps up to 11 conditionals per byte with a consistent single tuple index and function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me!
|
This should be zero and not one, the error was introduced in a rework on bluerobotics#110: https://github.com/bluerobotics/ping-python/pull/110/files#diff-ed2c04d88418d534a1ae078d8a994d08848d370ca71de0d0af5ab5f7b6f19d99R345 Signed-off-by: Patrick José Pereira <[email protected]>
This should be zero and not one, the error was introduced in a rework on #110: https://github.com/bluerobotics/ping-python/pull/110/files#diff-ed2c04d88418d534a1ae078d8a994d08848d370ca71de0d0af5ab5f7b6f19d99R345 Signed-off-by: Patrick José Pereira <[email protected]>
Up to 27% faster for Ping360 on 2M baud serial connection
calculate_checksum
to use built insum
instead of manual loop__slots__
toPingParser
parse_byte
to directly call the relevant function for the current stateERROR
status code to be in line with ping-cpp