• Raymond Hettinger's avatar
    Optimize string_repeat. · 93c213b6
    Raymond Hettinger authored
    Christian Tismer pointed out the high cost of the loop overhead and
    function call overhead for 'c' * n where n is large.  Accordingly,
    the new code only makes lg2(n) loops.
    
    Interestingly, 'c' * 1000 * 1000 ran a bit faster with old code.  At some
    point, the loop and function call overhead became cheaper than invalidating
    the cache with lengthy memcpys.  But for more typical sizes of n, the new
    code runs much faster and for larger values of n it runs only a bit slower.
    93c213b6
stringobject.c 98.7 KB