What works:
- raw_input, buffer etc. all fixers that can have their wildcards reduced
- isinstance, and all fixers with wildcards at the bottom
What doesn't:
- Alternatives: they seem easy to implement, will be added next week
- Wildcards at higher levels of the pattern: somewhat rare, left out for now (see the ws_comma for a case)
- Negative patterns: matching them should prevent the whole pattern from being matched. They rely on alternatives, so they are scheduled after them
The code is a bit hackish at points, using module globals to grab the AST leaves etc. But as I said, it's a draft. No optimization effort has been made since this was mainly a proof of concept. I'm planning for a rewrite when most functionality is complete, and the algorithm is proven to be faster.
Still, I was a bit disappointed that it ran slightly slower than the current version. I was expecting at least a tiny improvement. I expect the automaton to pick up some speed when it's properly simulated by a table, as it is currently run by traversing linked nodes. Plus we can use threads to... OK, I'm just kidding:)
The code enters at refactor.py:RefactoringTool.refactor_string, where refactor_tree is replaced with the new refactor_tree_btm. Some (horrible) changes have been made to pytree.py. The code can be found at the repository: http://code.google.com/p/2to3-speedup2/
No comments:
Post a Comment