[Python-bugs-list] [ python-Bugs-451622 ] xdrlib Packer performance-bug
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 16 Aug 2001 10:08:58 -0700
Bugs item #451622, was opened at 2001-08-16 09:29
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451622&group_id=5470
Category: Python Library
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Alex Martelli (aleax)
Assigned to: Nobody/Anonymous (nobody)
Summary: xdrlib Packer performance-bug
Initial Comment:
xrdlib.py's Packer class's pack_whatever functions all
work by self.__buf = self.__buf + something. If a
Packer is used to pack many data items, this leads to
degraded (quadratic) performance, like always when a
big string is built up by such concatenation of small
ones. Suggested fix: have a self.__aubuf auxiliary
list set to [] on __init__; change each concatenation
to __buf into self.__aubuf.append(something); in
method get_buffer, update the __buf "just in time" via
self.__buf += ''.join(self.__aubuf), then of course
self.__aubuf = [], before returning self.__buf to the
caller.
This may be fixed in other ways of course, but the
suggested fix seems very simple and safe.
Alex
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2001-08-16 10:08
Message:
Logged In: YES
user_id=21627
Instead of reinventing the wheel, I decided to use
cStringIO/StringIO to accumulate the bytes.
Committed as xdrlib 1.13.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451622&group_id=5470