-
Notifications
You must be signed in to change notification settings - Fork 467
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
Use cached PropertyNodes in python API for property reads #993
Use cached PropertyNodes in python API for property reads #993
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #993 +/- ##
=======================================
Coverage 24.87% 24.87%
=======================================
Files 168 168
Lines 18908 18908
=======================================
Hits 4704 4704
Misses 14204 14204 ☔ View full report in Codecov by Sentry. |
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.
So Python key hashing is faster than SGPropertyNode
name lookup ? 😄
Nice patch 👍, just a tiny comment: I think the dictionary should have a more explicit name such as properties_cache
.
Yep, key hashing definitely faster than property name lookup, plus we were doing 2 property name lookups/traversals. Initially via def __getitem__(self, key: str) -> float:
_key = key.strip()
pm = self.get_property_manager()
if not pm.hasNode(_key):
raise KeyError("No property named {}".format(_key))
return self.get_property_value(_key)
def get_property_value(self, name: str) -> float:
"""@Dox(JSBSim::FGFDMExec::GetPropertyValue) """
return self.thisptr.GetPropertyValue(name.encode()) |
Yes the code of Indeed, now that |
Ah, was wondering why it was coded that way. I'm used to the more aggressive form, "to kill two birds with one stone" 😉 |
Well, I'll try to pretend my error was made on purpose because aviation as a whole needs to be friendlier to the environment 😄 |
Based on performance tests in #977 implement the PropertyNode caching in the Python API for property reads.