Ask Your Question

Revision history [back]

Expanding on what niles said, you could have one function which is not cached and another that is. Run timeit on each one in the same Sage session.

If you have a method which is cached, then you can get around that by doing

sage: a = matrix(...)
# this will be fast because it calls the cached version:
sage: timeit('a.my_great_cached_method()')
# this won't be as fast, because the cache gets reset
# for each instance of the class:
sage: timeit('matrix(...).my_great_cached_method()')

There is no built-in way to tell timeit to ignore the cache, though.