string object methods vs string module functions

Emile van Sebille emile at fenx.com
Wed Oct 24 01:58:38 CEST 2001


"Robin Becker" <robin at jessikat.fsnet.co.uk> wrote in message
news:bkEne5AzFg17EwdY at jessikat.fsnet.co.uk...
> In a mailing to another list Steve Alexander <steve at cat-box.net> says
>
> > Various modules in Zope that used to use string functions a lot have
> > recently been converted to use string methods, and there was a noticible
> > speedup in performance as measured by benchmarks / testsuites.
>
> I would have thought this to be a minor speedup as the main work must
still be in C,
> but have others any thoughts/experiences on this? A function which
ReportLab uses a
> lot is join so my primitive hack test seems to bear out my intuition as
join
> performance seems very similar. Clearly I'm not actually testing this
properly, but
> are there any good disambiguating tests?

take from string.py, showing ''.join and string.join() are the same:

# Join fields with optional separator
def join(words, sep = ' '):
    """join(list [,sep]) -> string

    Return a string composed of the words in list, with
    intervening occurrences of sep.  The default separator is a
    single space.

    (joinfields and join are synonymous)

    """
    return sep.join(words)
joinfields = join

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list