Generate imports for assert only in debug mode#277
Merged
mikaelarguedas merged 2 commits intoros2:masterfrom May 24, 2018
martins-mozeiko:assert-imports
Merged
Generate imports for assert only in debug mode#277mikaelarguedas merged 2 commits intoros2:masterfrom martins-mozeiko:assert-imports
mikaelarguedas merged 2 commits intoros2:masterfrom
martins-mozeiko:assert-imports
Conversation
Member
|
Thanks @martins-mozeiko for the contribution. I pushed a fixup commit directly on this branch to use 4-space indentation for the Python code. CI: |
Member
|
Thanks @martins-mozeiko for the patch! |
34 tasks
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.
Reduce amount of imports are executed at runtime by doing them only when python runs in debug mode (
PYTHONOPTIMIZE=0). If python runs in optimized mode, assert statements are not executed, but currently there are a lot of imports happening. This patch moves imports insideif __debug__condition.This significantly reduces amount of import statements executed at runtime. We have seen significant performance gains on Raspberry Pi 3 when messages contain arrays - because accessing each array element would trigger many imports.