[Patches] [ python-Patches-1209527 ] Optimization for textwrap
SourceForge.net
noreply at sourceforge.net
Fri Jun 3 15:49:58 CEST 2005
Patches item #1209527, was opened at 2005-05-26 18:09
Message generated for change (Comment added) made by jepler
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1209527&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Connelly (connelly)
Assigned to: Greg Ward (gward)
Summary: Optimization for textwrap
Initial Comment:
This patch speeds up the textwrap module, so that it
takes O(n) time to process n chunks rather than the
O(n^2) time that textwrap previously took.
This makes textwrap much faster for large texts (for
example, the patched version runs textwrap.fill('foo' *
100000) 80 times faster than the unpatched version).
----------------------------------------------------------------------
Comment By: Jeff Epler (jepler)
Date: 2005-06-03 08:49
Message:
Logged In: YES
user_id=2772
I didn't benchmark the speed increase, but I verified that
on my system 'test_textwrap.py' still completes
successfully. I also looked at the patch and found the
change to be straightforward. However, I wonder if the
speed increase would be nearly as great if
collections.deque was used instead of the reversed list.
Unfortunately, the textwrap module seems to intend
portability with older versions of Python, which would not
work if the collections module is used.
----------------------------------------------------------------------
Comment By: Connelly (connelly)
Date: 2005-05-27 11:37
Message:
Logged In: YES
user_id=1039782
I assign the Copyright for this patch to the Python Software
Foundation.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1209527&group_id=5470
More information about the Patches
mailing list