[issue7826] support caching for 2to3

Brian Harring report at bugs.python.org
Mon Feb 1 02:24:34 CET 2010


Brian Harring <ferringb at gmail.com> added the comment:

Attached is a derivative of http://pkgcore.org/trac/pkgcore/browser/ferringb/snakeoil-dev/snakeoil/caching_2to3.py

As you can see in that function, some nastyness is required right now to slip it in w/out duplicating code (hence the first patch).

Patch attached here inlines the support directly into a new module lib2to3.caching, and derives on the fly a caching version of the RefactoringTool.

The on the fly bit is somewhat fancy I admit, but was done so that anyone using an alternate RefactoringTool can get the same benefits.

The sole con to this functionality is that it assumes the transformation will always be the same; in other words, it doesn't account for --fix/--nofix, nor changes in the transformation algorithms that would result in  differing output.

Personally for my uses this was completely valid- when changing the python version (even a minor upgrade) on my buildslaves I'd wipe the caches to be safe anyways.

That said, if there *is* interest in getting caching into stdlib for this, I can poke through the code and incorporate awareness of nofix/fix/python version into the cache key.  I skipped doing that however since I didn't think there was a chance in hell of caching going into mainline however ;)

Either way, for folks targeting py2k and using buildslaves to validate their code and the translation of said code for py3k, either of these patches really is needed to support caching and stop burning cycles.

----------
Added file: http://bugs.python.org/file16078/2to3-caching.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7826>
_______________________________________


More information about the Python-bugs-list mailing list