From: Keith G. <kwg...@gm...> - 2006-07-04 01:53:36
|
On 7/2/06, Webb Sprague <web...@gm...> wrote: > Given the long history of python and its ancestry in C (for which zero > based indexing made lots of sense since it dovetailed with thinking in > memory offsets in systems programming), there is probably nothing to > be done now. I guess I just want to vent, but also to ask if anyone > has found any way to deal with this issue in their own scientific > programming. Aha! Guido himself prefers starting the index at one. Here's a code snippet from a fun article he wrote about optimizing python code: import time def timing(f, n, a): print f.__name__, r = range(n) t1 = time.clock() for i in r: f(a); f(a); f(a); f(a); f(a); f(a); f(a); f(a); f(a); f(a) t2 = time.clock() print round(t2-t1, 3) http://www.python.org/doc/essays/list2str/ Notice he chose t1 and t2 instead of t0 and t1. QED |