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. |
bcoconni
left a comment
There was a problem hiding this comment.
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.