[issue15522] impove 27 percent performance on stringpbject.c( by prefetch and loop optimization)

abael report at bugs.python.org
Sat Aug 4 10:00:22 CEST 2012


abael added the comment:

added my implement( with some enhancement, got better performance, at less
for my apps. ).

test result:
with small chunk of str, got double performanc,
and 111% for big chunks;  it

## Util funcion for text definition:
def pf(f,n):
    a=time()
    for i in xrange(n):
        f()
    b=time()
    print  n/(b-a)

#############################################################################
>>> s=['abcd',u'\u548c\u6613\u541b'] * 1000
>>> pf(lambda:''.join(s), 10000)
2289.28293164
>>> pf(lambda:text.join('',s), 10000)
4457.27947763
>>> s=['abcd'*1000,u'\u548c\u6613\u541b'*1000] * 1000
>>> pf(lambda:''.join(s), 100)
15.2374868484
>>> pf(lambda:text.join('',s), 100)
16.939913023

##############################################################################

2012/8/1 Antoine Pitrou <report at bugs.python.org>

>
> Antoine Pitrou added the comment:
>
> Hi, several points:
>
> - Python 2.7 is in bugfix mode; you need to work from the default
> Mercurial branch as explained in http://docs.python.org/devguide/ . In
> practice, this means your patch will target the future Python 3.4, and
> therefore either PyUnicode_Join or _PyBytes_Join.
>
> - please provide an actual patch (a Mercurial diff, probably)
>
> - please provide benchmarks (using e.g. timeit) which demonstrate the
> performance improvement you are proposing
>
> ----------
> nosy: +pitrou
> versions: +Python 3.4 -Python 2.7
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue15522>
> _______________________________________
>

----------
Added file: http://bugs.python.org/file26681/stringjoin.c

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15522>
_______________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stringjoin.c
Type: text/x-csrc
Size: 2831 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-bugs-list/attachments/20120804/7dc00ae1/attachment-0001.c>


More information about the Python-bugs-list mailing list