> I don't think the intention to compile Cython should impact our design
> decisions. If a Cython compiled Cython compiler is not any faster than a
> Python based one, then that's a reason to improve Cython, not its code.

The issue here is that using the "classical visitor pattern" is 
theoretically a much more likely candidate for optimization than 
dict-based visitors.

Consider them different algorithms which currently perform at equal 
speed, but one of them has a much higher potential for hypothetical 
future optimization. No matter how smart Cython becomes it cannot switch 
to faster algorithms...

 >> The issue Gary has is indeed with raw
 >> dict lookup performance. (Consider that this will be between 10 and 50
 >> times to every single node in the tree of a file.)
 >
 > Unless you annotate a parse tree with all its transformers in one 
traversal step.

This is highly non-trivial though -- the output of one transform is 
changed and new nodes, which are the input to the next transform. And, 
the output of one "node transform" is potentially dependant on anything 
in child nodes, parent nodes, sibling nodes etc.

To get anywhere one would at least have to put in restrictions on what a 
node visitors was allowed to read from the tree (likely inspect children 
and ancestors but not following-siblings). And still it is not simple. 
Let's do that when everything else is working :-)

 > What about just using plain old "cdef" to make it valid Cython code, 
and then
 > run a cy2py tool over it in setup.py that strips it down into valid 
Python
 > code? That's how 2to3 works. The tool could just bail out if it finds 
anything
 > that's not pythonisable, such as cimports and C pointer types.
 >
 > The down side is obviously that this would prevent us from running 
Cython from
 > the source directory ...

Good idea. (I actually hope nothing like this is attempted for a while, 
but what our possibilities are affects how visitors are written...).

Still my own summary is: This doesn't matter that much now -- the 
important thing is getting visitors at all. No matter what solution is 
picked, going from one to the other will take about a day of 
conceptually very simple work. So I'm still for dict-based; allows us to 
move faster, until something like the above is actually in place.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to