On Thursday, June 7, 2018 at 10:11:25 AM UTC-5, Edward K. Ream wrote:

#927 <https://github.com/leo-editor/leo-editor/issues/924> performance 
> questions has revealed some performance gains. 
>

Rev 8fef84f5 completes work on the "perf" branch.  I plan no further work, 
except to merge the branch into "devel".

*Biggest gains*

Shortcutting g.isUnicode and g.toUnicode was easy, and removes a huge 
number of function calls.

Rewriting g.is_special and sc.createAllButtons saves lots of calls to 
g.match_word.

Rewriting g.match_word so it uses regex patterns is much trickier than one 
might suppose. I have failed repeatedly to do so.  For now, it will stay as 
it is. It no longer is any kind of performance gotcha.

*Better tracing*

The following code snippet is extremely useful.

if not g.app.statsLockout:
    g.app.statsLockout = True
    try:
        d = app.statsDict
        key = 'g.isUnicode:' + callers()
        d [key] = d.get(key, 0) + 1
    finally:
        g.app.statsLockout = False

g.printStats now assumes that stats were created by the snippet above.

Furthermore, there is now a 'print-stats' command that simply calls 
g.printStats.

*Loose ends*

1. It turns out that Leo's generators return* copies* of positions on 
purpose. This is the safe way for most users/scripts, though perhaps a 
no_copy kwarg might be reasonable.  The drawing code would benefit most, 
but the benefit isn't likely to be huge. For now, I'll leave the code as it 
is.  

The calls to p/v.headString() look fairly benign. Using the method, rather 
than v._headString directly allows a consistency check.  Again, the code 
looks good enough as it is.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to