On Tue, 02 Nov 2010 14:38:14 +1100 Steven D'Aprano steve@pearwood.info wrote:
Alexander Belopolsky wrote:
Well, yes, it does, but:
(1) How many people would think to look in timeit for this function? Both you and Kristján were apparently surprised that it already exists, and I'd bet money that you weren't the only ones. timeit seems to be more of an application than a library (although I acknowledge the border between the two is fuzzy), and people don't think about using it as a library.
(2) The time module is the natural place to look for time-related functions. It would be nicer if timeit could import the default timer from time:
from time import timer as default_timer # or wall_clock if you prefer
(3) The default_timer is an implementation detail of timeit. It could change, or disappear, or be renamed. You'll note it isn't documented:
http://docs.python.org/library/timeit.html
(4) I started off thinking that we should just document timer (wall_clock) as an alias to one of time() or clock(), but I changed my mind. That's an implementation detail that we should be free to change in the future. For the sake of information hiding, we shouldn't promise that the timer will be one of time.clock() or time.time(). Who knows, maybe there are (or will be someday) supported platforms where neither choice is appropriate, and the timer needs to be something else?
Very good summary of the present issue. I think the proposed solution is just what we need.
Denis -- -- -- -- -- -- -- vit esse estrany ☣
spir.wikidot.com