Equivalent of Perl chomp?

John Machin sjmachin at --nospam--lexicon.net
Thu Jan 31 20:18:48 EST 2002


"Mark McEahern" <marklists at mceahern.com> wrote in message
news:mailman.1012509053.25355.python-list at python.org...
> Tim Peters wrote:
> > Note that
> >
> >     s.endswith('\n')
> >
> > is clearer than
> >
> >     s[-1:] == '\n'
> >
> > For real fun, time them <wink>.
>
> I timed them with the following code and it occurred to me here's a
possibly
> good case where aspect-oriented programming would be nice.  Anyway, the
> results first:
>
> <function endsWith at 0x100f94d0> : 0.36 seconds.
> <function sliceIt at 0x100f9510> : 0.07 seconds.
>

The supplied code seems to be timing ONE iteration on a string that's
100,000,001 bytes long.
The point of that exercise would be ________________________.







More information about the Python-list mailing list