Stefan Behnel wrote: > Dag Sverre Seljebotn wrote: >> Stefan Behnel wrote: >>> That makes me wonder if it's not worth using such an implementation for >>> >>> cdef dict d >>> ... >>> for (key|value|key,value) in d.iter(keys|values|items)(): >>> ... >>> >>> internally - but *only* for the ".iter*()" variants to avoid introducing >>> problems with dict modification during iteration. That would be a pretty >>> cool optimisation. The generic loop code we currently generate is huge >>> compared to a straight call to PyDict_Next(). >>> >>> Maybe a tree transformation could replace the for-loops above with a new >>> DictLoopNode that would generate the respective code. >> +1, good idea -- though I'd definitely not have a DictLoopNode; instead >> one should use a regular WhileStatNode containing a SimpleCallNode >> calling PyDict_Next. The direction things should be taking is less loop >> node types, not more (e.g. transform ForInStatNode into WhileStatNode if >> an iterator is used). (See also: The copy&paste-style code duplication >> going on in the generate_..._code-implementations of the current looping >> nodes.) > > Very true. I just noticed that when I looked through the current > implementations. There's also the range() optimisation which could be done > with a tree transform now that we have them in place. >
Be aware of the TempsBlockNode I wrote if you look at this, for any temporary variables needed. (It is currently unused so may have bugs too...ask if you have problems with it) -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
