-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Memoize attribute listeners to not call them on equal values. #446
Conversation
Fantastic.. I thought we'd decided to just live with this. - pleased to be mistaken. I've added the docs and example updates to support this change. I guess I should point out that this is good but not silver bullet for users. Some attributes like gps location will drift a bit and show changed values even though the real position has not changed. Still pretty cool. ISSUE: Only issue is that the vehicle_state.py example has the following crash while waiting for home position first time you connect. This happens if you run the example against dronekit-sitl copter first time (of anything that is connecting to the SITL). After if fails you can connect again and you don't see this problem...
However you see it again when the code gets a bit further - same problem with downloading waypoints ...
|
@hamishwillee So I updated this PR again (it again passes tests). This is actually much trickier than I expected, partly because some objects don't change their equality ( So I added a |
@hamishwillee Also "memoize" is the correct term, not memorize 👼 |
@tcr3dr Learn something new every day - "memoize" indeed! That sounds like a pragmatic solution to an ugly problem. I'll update the documents now. I guess it was probably a good idea to dump my last set of changes. |
@hamishwillee Did you upload a change I overwrote again? Gah. |
@tcr3dr Nope, not overwritten anything yet - though you did kill my last changes. I am about to update the docs now. |
@tcr3dr Docs updated now. They need a scan from you - my brain starting to ooze :-( |
@hamishwillee Reviewed the docs—they look stellar, so good work! |
Memoize attribute listeners to not call them on equal values.
@tcr3dr Gad you like them. I needed the check as I noticed I'd been sloppy with some example cleanup ... happens more as you get tired. |
See #60. Memoization seemed like the "cheapest" approach: not up to the end user to maintain state and observe changes, instead, implemented at the level of attribute listening.