Which is faster?

Peter Otten __peter__ at web.de
Thu Jan 27 03:17:33 EST 2005


Aggelos I. Orfanakos wrote:

> Any idea which of the following is faster?
> 
> 'a/b/c/'[:-1]
> 
> or
> 
> 'a/b/c/'.rstrip('/')

Don't ask for the speed, decide whether you want to transform

"a/b/c" --> "a/b/c"
"a/b/c//" --> "a/b/c"

or

"a/b/c" --> "a/b/"
"a/b/c//" --> "a/b/c/"

That is much more important.

Peter




More information about the Python-list mailing list