module ns access vs. local access vs. builtin methods

Skip Montanaro skip at pobox.com
Mon Jul 16 11:36:45 EDT 2001


    Roman> I've got interesting profile results which show that
    Roman> using string methods is faster than other optimisation tricks:

    [string.split vs. ssplit=string.split vs s.split]

    Roman> a3 is clear winner, which probably mean that calling methods of
    Roman> built-in types is faster than calling functions.

The string method version is guarateed to be the fastest, no matter what you
do with string.split because in 2.x string.split(s) is implemented as
s.split().  No matter what you do with the string module you're going to
work harder than just calling the split method directly.

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list