Skip to content

check for existence of joint channel when getting frames#4

Merged
rdeioris merged 1 commit into20tab:masterfrom
OlafHaag:master
Aug 16, 2018
Merged

check for existence of joint channel when getting frames#4
rdeioris merged 1 commit into20tab:masterfrom
OlafHaag:master

Conversation

@OlafHaag
Copy link

I propose a fix for issue #3 .
The if-else block seems to be a good trade-off in comparison to a try-except block concerning speed. I did some tests with timeit.
timeit(setup="l=['Xposition', 'Yposition', 'Zposition', 'Xrotation'];a='Zrotation'", stmt="if a in l:\n b=l.index(a)\nelse:\n b=-1")
vs.
timeit(setup="l=['Xposition', 'Yposition', 'Zposition', 'Xrotation'];a='Zrotation'", stmt="try:\n b=l.index(a)\nexcept ValueError:\n b=-1")
The performance of if-else is slower than try-except when the channel you're looking for exists, but the penalty for try-except seems much higher when the channel doesn't exist, whereas the if-else statement executes even faster.

@gabbork gabbork requested a review from rdeioris August 15, 2018 20:08
@rdeioris rdeioris merged commit 15fbe6a into 20tab:master Aug 16, 2018
rdeioris pushed a commit that referenced this pull request Aug 16, 2018
@rdeioris
Copy link
Contributor

Thanks, added related test:

ed8c963

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.

2 participants