03.08.17 19:08, Ian Kelly пише:
This turns out to be because I was running 3.4 which doesn't have the
C implementation to begin with. In 3.6 this trick doesn't seem to work
as expected for disabling it:
It didn't work because the functools module already was imported at startup.
$ ./python -m timeit -s 'from simple_cache import simple_cache; f =
simple_cache(int)' -- 'f()'
500000 loops, best of 5: 501 nsec per loop
$ ./python -m timeit -s 'from functools import lru_cache; f =
lru_cache(maxsize=None)(int)' -- 'f()'
2000000 loops, best of 5: 139 nsec per loop
$ ./python -m timeit -s 'import sys; sys.modules["_functools"] = None;
del sys.modules["functools"]; from functools import lru_cache; f =
lru_cache(maxsize=None)(int)' -- 'f()'
100000 loops, best of 5: 3.39 usec per loop
--
https://mail.python.org/mailman/listinfo/python-list