Aggelos I. Orfanakos wrote:

> Any idea which of the following is faster?
> 
> 'a/b/c/'[:-1]
> 
> or
> 
> 'a/b/c/'.rstrip('/')
> 
> Thanks in advance.
> 
> P.S. I could time it but I thought of trying my luck here first, in
> case someone knows already, and of course the reason.

First, it almost certainly doesn't matter. Use the one that is
self-documenting.

Secondly, time it yourself. It's incredibly easy. There's a module
written especially for doing this - and surprise surprise, it's called
"timeit.py" and it's in the <python install location>/Lib directory.

Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to