Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not a complete answer but some suggestions:</p> <ol> <li><p>Can you eliminate the value comparison? Of course that's a feature change of your implementation. But the overhead in runtime will be even worse if more complex objects than integers are being stored in attributes.</p></li> <li><p>Every call to a method via <code>self</code> needs to go through full method resolution order checking. I don't know if Python could do any MRO caching itself. Probably not because of the types-being-dynamic principle. Thus, you should be able to reduce some overhead by changing any <code>self.method(args)</code> to <code>classname.method(self, args)</code>. That removes the MRO overhead from the calls. This applies to <code>self.setModified()</code> in your <code>settattr()</code> implementation. In most places you have done this already with references to <code>object</code>.</p></li> <li><p>Every single function call takes time. You could eliminate them and e.g. move <code>setModified</code>'s functionality into <code>__setattr__</code> itself.</p></li> </ol> <p>Let us know how the timing changes for each of these. I'd split out the experiment. </p> <p>Edit: Thanks for the timing numbers.</p> <p>The overhead may seem drastic (still a factor of 10 it seems). However put that into perspective of overall runtime. In other words: How much of you overall runtime will be spent in setting those tracked attributes and how much time is spent elsewhere?</p> <p>In a single-thread application <a href="http://en.wikipedia.org/wiki/Amdahl%27s_law" rel="nofollow">Amdahl's Law is a simple rule</a> to set expectations straight. An illustration: If 1/3 of the time is spend setting attributes, and 2/3 doing other stuff. Then slowing down the attribute setting by 10x will only slow down the 30%. The smaller the percentage of time spent with the attributes, the less we have to care. But this may not help you at all if your percentage is high...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload