So I am looking for what's next in my life.
>
>  Edward
>

Perhaps you might want to tackle again outline drawing code. Here is a 
simple script that shows how much faster can be tree traversal.


import timeit

def f():
    def it(root, lev):
        yield root, lev
        for v in root.children:
            yield from it(v, lev+1)
    return list(it(c.hiddenRootNode, 0))

def f1():
    return [(p.level(), p.v.fileIndex) for p in c.all_positions_iter()]

def report(fun, n=100):
    t = timeit.timeit(fun, number=n)/n * 1000
    g.es('function %s took %.1fms'%(fun.__name__, t))
report(f, 10)
report(f1, 10)
g.es(len(f()))


On my machine and in my copy of LeoPyRef.leo, this script gives the 

following output:


function f took 9.1ms
function f1 took 46.7ms
8343


That is more than 5 times faster. So, even if the rest of the drawing code 
remains unchanged, it would be much faster if the traversal is done without 
using positions.


There are also many other parts of Leo that depend on the position 
traversals. At least some of them could use direct traversal as in the 
script above.


Vitalije

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
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