compile_internal generates the cache key

Passing a cache key to compile_internal is error prone and
laborious, so this commit changed compile_internal to generate the
cache key. This also enables caching for all calls to it, some of
which were previously not enabled because they passed no
cache_key.

This also adds a test for the caching, which checks the size of
the cache after the compilation of functions to determine whether
the cache is being used correctly.
Add additional check with different type

Add an additional check for the same function with a different
signature, in order to ensure that the cached version isn't
incorrectly picked up.

Also simplify len(list(...)) to len(...)
Add docstring, remove keys() in test_compile_cache
Merge pull request #839 from gmarkall/autogenerate_cache_key

`compile_internal` generates the cache key