[Patches] [ python-Patches-976162 ] Deferred String Addtion:
Proof-of-concept
SourceForge.net
noreply at sourceforge.net
Tue Jun 22 00:28:35 EDT 2004
Patches item #976162, was opened at 2004-06-20 05:10
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=976162&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 1
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: Deferred String Addtion: Proof-of-concept
Initial Comment:
The attached patch demonstrats a possible
implementation for
deferred string addition. The idea is to have
str.__add__ save references to its inputs rather that
do the concatenation immediately. The moment some
other method needs the full string, it is generated
recursively so that the whole concatenation can be done
with a single join.
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-06-21 23:28
Message:
Logged In: YES
user_id=80475
The patch is not meant to be loaded to UserString. Rather
it is a proof-of-concept demonstration of how deferred
string addition would work. Even it pure python form, it
shows how to convert an O(n**2) process to O(n). If the
concept is approved, the goal is to alter the C code for
stringobject.c, unicodeobject.c, and to make a more thorough
version for UserString.
----------------------------------------------------------------------
Comment By: Jim Jewett (jimjjewett)
Date: 2004-06-21 09:31
Message:
Logged In: YES
user_id=764593
There is an implicit assumption that any component/part with
its own 'components' attribute will be another UserString (or,
at the very least, will act like one when traversed).
Would it be better to check whether the subobject actually is
a UserString (since new-style objects can freely use multiple
inheritance), or to do some sort of guard in add? (Perhaps
immediately stringifying anything with a components attribute
that is not a UserString?)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=976162&group_id=5470
More information about the Patches
mailing list