sympy/sympy — pull request #2448 by gilbertgede (2013-09-10 22:03:29+00:00)
Title: WIP: Localized Caching

A different approach to caching in SymPy.

Instead of the previous approach, where various methods were decorated with `@cacheit` to show that their output should be cached, there are now 2 decorators: `@user_cacheit` and `@cacheit`. The new method has "user-level" functions/methods decorated with the `@user_cacheit`. This turns on a flag, and upon exiting the first called user-level method with this decorator, it clears the cache (and turns off that flag). The `@cacheit` decorator now only looks to the cache in the case where the flag is on - otherwise it operates normally.

It's kind of rough, but I believe all tests were passing, with only a moderate slowdown. There is probably lots of work to do - better naming, adding/removing methods to be "user-cached" and "hidden-cached", etc.