PEP proposal: enhanced string functions

Stephen Ferg steve at ferg.org
Fri Nov 16 16:33:38 EST 2001


One of the questions raised by the proposal for extending strip()
functionality is --

     How much would such a language feature would be used?

Basically, it is a request for a cost/benefit analysis.  We want to
know whether the added benefit of implementing it in the language
would be worth the effort that it cost.

A couple of days ago, I realized that I had the material for an
empirical investigation of this question.  I have a legacy system of
about 52,000 lines of code.  It is very text-processing intensive, and
it is written in REXX, a language that supports the kind of extended
strip() functionality that was proposed for Python.

I realized that I could count the occurrences of the extended strip()
functionality in this system.

The most that we could say after such an investigation would be that
we had some hard numbers from a single system that was text-processing
intensive. But surely that was better than nothing.

What I found was that more than a third (36%) of the invocations of
strip() used the option of stripping other-than-whitespace characters.
 Here are the actual numbers.


Number of lines of code  : 51605
Number of uses of strip  : 380

uses of  strip()         : 223
uses of lstrip()         :   8
uses of rstrip()         :  13
==========================
Total                      244   (64%)


uses of  strip(stripchar):  52
uses of lstrip(stripchar):  16
uses of rstrip(stripchar):  68
==========================
Total                      136   (36%)


These numbers suggest that if this functionality were available in
Python, it certainly would be used.

-- Steve Ferg
steve at ferg.org



More information about the Python-list mailing list