Hi, Dag Sverre Seljebotn wrote: > Gary recently voiced concern over dict-based visitor lookups perhaps > giving a speed penalty
Why? You could use lazy initialisation. Just look up a node type in the dict (which is fast) and if it's not in there yet, walk it's base types (adding each one to the dict) until there is one that already is in the dict, which then determines the result for the lookup and for the newly added base types. That way, you'd quickly end up with a complete flattened type hierarchy in the dict. The total number of dict updates will be <= the total number of node types and the time for a node type lookup is still O(1). The type registration would follow the same algorithm as a lookup, but the new callbacks would be added to the results of the found base types. > I think we > definitely want Cython to be runnable in Python, so that we don't have > to ship Cython in .c-form to people who don't already have Cython > installed, not to mention having to "bootstrap" any new Cython feature > using the current Cython features (agreed or not?) Running it in C will only ever be an optimisation, possibly triggered by an option to setup.py that will compile Cython using Cython itself before installing it as binary module. > Is there going to be a way to have this (i.e., vtable-based Cython) in > the foreseeable future? Using decorators certainly comes to mind, > however that breaks 2.3 support. Perhaps special comments? > > #cython: cdef Visitor: > class Visitor: Robert already stated his opinion on this a couple of times and I second it: hiding code semantics in Python comments is a bad idea. We should only do this if we really find we can't do something any other way. I don't see that here. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
