Slicing vs .startswith

Shu-Hsien Sheu sheu at bu.edu
Mon Sep 22 11:17:53 EDT 2003


Hi,

I have a question about the comparison of efficiency of string slicing 
and using string.startswith.
For example, which one of the following would be more efficient, or , 
moreover, more pythonic?

if aa[:3] == 'abc':

vs

if aa.startswith('abc'):


Thanks!

-shuhsien






More information about the Python-list mailing list