sympy/sympy — pull request #7688 by pbrady (2014-07-03 17:12:56+00:00)
Title: Fix inconsistent caching/matching behavior

Old behavior is documented in #7687 and repeated here:

```python
[ptb@cyrus sympy]$ ipython
Python 3.4.1 |Continuum Analytics, Inc.| (default, May 19 2014, 13:02:41)
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: from sympy import Function

In [2]: from sympy.abc import x

In [3]: f = Function('f')(x)

In [4]: ff = Function('f')(x)

In [5]: ff.match(f)
Out[5]: {}

In [6]: from sympy.core.cache import clear_cache

In [7]: clear_cache()

In [8]: ff = Function('f')(x)

In [9]: ff.match(f)

In [10]: f.__class__ is ff.__class__
Out[10]: False

In [11]: f.__class == ff.__class__
Out[11]: True
```
Note that 10 and 11 are there to highlight the change needed in `matches` to make the behavior consistent between `cache_clears` or when using a bounded cache as in #7464

New behavior
```python
In [1]: from sympy import Function

In [2]: from sympy.abc import x

In [3]: f = Function('f')(x)

In [4]: ff = Function('f')(x)

In [5]: ff.match(f)
Out[5]: {}

In [6]: from sympy.core.cache import clear_cache

In [7]: clear_cache()

In [8]: ff = Function('f')(x)

In [9]: ff.match(f)
Out[9]: {}

In [10]:
```