Kent Johnson wrote:
Marilyn Davis wrote:
> Is there a reason to prefer one over the other? Is one faster? I
> compiled my regular _expression_ to make it quicker.
The only way to know which is faster is to time them both. The timeit module makes it pretty easy to
do this.
Here is a simple example of using timeit for a different problem; you can adapt it to your own needs:
d = dict( ((i,i,i), i) for i in range(1000))[cut]
I was glad to see your post showing how to run a list of functions through the timer. That's a nice way to do it! You better slip some square brackets into your definition of d though:
d = dict( [((i,i,i), i) for i in range(1000)])
/c
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor