-
Notifications
You must be signed in to change notification settings - Fork 5
Capability organisation #42
Comments
Forgot to mention: Cases where a node needs to iterate over all capabilities to find the capability with a certain name should be minimal. The |
I've been working on this @z25. But the essence of how I was thinking of the capability tree:
self.values:
self.callbacks
Hope it is self explanatory. Basically values are referred to through a lookup tables. Same counts for getters and setters. Still have to think about concurrent implications though. |
But the above still has the capabilities as a dict, instead of a list. It has a "signalid", but I would think that a "capabilityid" would be a better idea in the new model where every capability can be an emitter and/or a receiver. I propose that this "capabilityid" would simply be the index in the capability list. |
I know. I was only changing the capability description to bypass Indeed the capabilities can be a list of dicts. This protects the order. I don't follow why the capability ids? The capabilities describe much more On Thu, 18 Dec 2014, Aldo Hoeben wrote:
|
I've tested dictionary modification and list modification. I wanted to know the performance difference. I created a simple capability tree and modified values on it. The same modification I also did in a list mimicking a lookup table of values: Results of three runs are:
python3:
In general it is twice as fast.
|
I've added another test using a dict (hashmap) as a LUT. To make it bit more real I used three characters for the identifier. Actualy I found a small issue in the first test since the measurement included generating the list. The list is thus a bit faster.
|
@fieldOfView : "I propose that this "capabilityid" would simply be the index in the capability list." |
By "object" you mean "capability"? There currently is no way to remove a capability from the tree. Of course a node could unset a capability, but there is no way to communicate this to the other nodes because (partial) trees sent with a MOD message are merged with the current tree. Do we want to be able to mark a capability as deleted/inactive/permanently disabled? That way, all indices would be maintained. |
ow yes by object I meant an entry in the objects list. Eventually I think we will need to support some way of removing objects again from the list. It's like the hitman approach. Always cleanup after a job. Perhaps then it might be better to enhance MOD with adds, updates and deletes? |
K, I've done some more metric tests. Contrary to my belief using an array or a numpy array is even slower for our purpose. Numpy and arrays are apparently designed for large data. 1 million operations on 10 values in an dict/list/array:
However same test in C using an array:
See also: http://stackoverflow.com/a/23331775 |
Also nice to see metrics from pypy:
|
K, made a slight brain error. We can't use arrays for our values as we can't mix value types in arrays. So I was thinking about getters and setters again and it turns out Python does have an approach to that:
gives:
|
Interesting discussion: openframeworks/openFrameworks#1391 |
I was looking into having a zocp property class which wraps any object. I'm not there yet as I can't copy the class attributes but the structure does work:
|
K another thought iteration. Here's a pseudo class of a ZOCP parameter (or what we call it) Here's some code:
|
Started a new branch |
I also made some changes to the node editor. However it takes some more changes to go from signal names to signal ids. https://github.com/sphaero/pyZNodeEditor/tree/capability_refactor |
Nodeeditor now works with capability reorganisation although I reckon it should be coded different. |
Currently the capabilities of a node is a dict, keyed by the name of each capability. The both the get/set, mod and signals implementations use this name to communicate the capability reference. This has a couple of disadvantages:
Capabilities could instead be stored in a list. The index of a capability in the list could be used to reference the capability in set/get/mod/sig/sub/unsub messages, as it is unique and does not change over the lifetime of a node.
The text was updated successfully, but these errors were encountered: