If str.startswith()
and str.endswith()
didn’t support tuples, I’m not even sure that the proposal to add support for tuples would be accepted now. s.endswith(('.py', '.pyc')) has too little advantage over
s.endswith(‘.py’) or s.endswith(‘.pyc’)`.
For str.find()
and str.split()
the benefits may be greater, but these cases are rarer and are covered by the re
module.
It is also not obvious how to implement them effectively in C – there are two stright ways (one is used in os.path
implementations, and other in the re
module), and which of them is faster depends on the nature of the date. In any case an efficient implementation will add many tens or hundreds lines of the C code to save few Python lines here and there. Not every few lines of Python code deserve adding a builtin function or method.