New submission from Peter Brady:
The SymPy project (https://github.com/sympy/sympy) makes heavy use of caching
to speed up the creation of symbols and expressions. If available, we make use
of the fastcache library (https://github.com/pbrady/fastcache) - an lru_cache
written in C. Otherwise we use lru_cache provided by functools. When testing
with 3.5, we started to observe `KeyError`s coming from the new lru_cache
implementation in _functoolsmodule.c. There was some discussion on this on the
SymPy mailing list here
https://groups.google.com/forum/#!topic/sympy/AnwYTJGRBB4.
Here's an example of the failure in the SymPy test suite (Note that this
failure does not occur if we use the lru_cache in 3.4 or fastcache or if we use
the lru_cache in 3.5 with no size limit)
$ /usr/local/opt/python-3.5/bin/python3
Python 3.5.0 (default, Oct 1 2015, 21:51:43)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import test
>>> test("test_frame.py")
= test process starts ==
executable: /usr/local/opt/python-3.5/bin/python3 (3.5.0-final-0)
[CPython]
architecture: 64-bit
cache: yes
ground types: python
random seed:7625225
hash randomization: on (PYTHONHASHSEED=2787593824)
sympy/physics/vector/tests/test_frame.py[4] .EE. [FAIL]
sympy/physics/vector/tests/test_frame.py:test_ang_vel _
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/tests/test_frame.py",
line 66, in test_ang_vel
B = A.orientnew('B', 'Axis', [q2, A.x])
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/frame.py",
line 640, in orientnew
newframe.orient(self, rot_type, amounts, rot_order)
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/frame.py",
line 523, in orient
[-axis[1], axis[0], 0]]) * sin(theta) + axis * axis.T)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/cache.py",
line 93, in wrapper
retval = cfunc(*args, **kwargs)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/function.py",
line 375, in __new__
result = super(Function, cls).__new__(cls, *args, **options)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/cache.py",
line 93, in wrapper
retval = cfunc(*args, **kwargs)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/function.py",
line 199, in __new__
evaluated = cls.eval(*args)
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/functions/elementary/trigonometric.py",
line 459, in eval
if arg.could_extract_minus_sign():
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/expr.py",
line 2047, in could_extract_minus_sign
negative_self = -self
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/expr.py",
line 113, in __neg__
return Mul(S.NegativeOne, self)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/cache.py",
line 93, in wrapper
retval = cfunc(*args, **kwargs)
KeyError: (, 1, B_y, sin(2*q(t)), , ,
, sin)
__ sympy/physics/vector/tests/test_frame.py:test_dcm ___
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/tests/test_frame.py",
line 131, in test_dcm
B = A.orientnew('B', 'Axis', [q2, A.x])
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/frame.py",
line 640, in orientnew
newframe.orient(self, rot_type, amounts, rot_order)
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/physics/vector/frame.py",
line 523, in orient
[-axis[1], axis[0], 0]]) * sin(theta) + axis * axis.T)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/cache.py",
line 93, in wrapper
retval = cfunc(*args, **kwargs)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/function.py",
line 375, in __new__
result = super(Function, cls).__new__(cls, *args, **options)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/cache.py",
line 93, in wrapper
retval = cfunc(*args, **kwargs)
File "/home/peter/.local/lib/python3.5/site-packages/sympy/core/function.py",
line 199, in __new__
evaluated = cls.eval(*args)
File
"/home/peter/.local/lib/python3.5/site-packages/sympy/functions/elementary/trigonometric.py",
line 459, in eval
if arg.could_extract_minu