Alex Gaynor avatar Alex Gaynor committed ae4392b

Remove unused strjoin option

Comments (0)

Files changed (8)

pypy/config/pypyoption.py

                    requires=[("objspace.std.withsmallint", False)]),
                              #  ^^^ because of missing delegate_xx2yy
 
-        BoolOption("withstrjoin", "use strings optimized for addition",
-                   default=False),
-
         BoolOption("withstrslice", "use strings optimized for slicing",
                    default=False),
 
         config.objspace.std.suggest(withprebuiltchar=True)
         config.objspace.std.suggest(withmapdict=True)
         config.objspace.std.suggest(withstrslice=True)
-        config.objspace.std.suggest(withstrjoin=True)
         if not IS_64_BITS:
             config.objspace.std.suggest(withsmalllong=True)
 

pypy/doc/config/objspace.std.withstrjoin.txt

-Enable "string join" objects.
-
-See the page about `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#string-join-objects
-
-

pypy/doc/interpreter-optimizations.rst

 String Optimizations
 --------------------
 
-String-Join Objects
-+++++++++++++++++++
-
-String-join objects are a different implementation of the Python ``str`` type,
-They represent the lazy addition of several strings without actually performing
-the addition (which involves copying etc.). When the actual value of the string
-join object is needed, the addition is performed. This makes it possible to
-perform repeated string additions in a loop without using the
-``"".join(list_of_strings)`` pattern.
-
-You can enable this feature enable with the :config:`objspace.std.withstrjoin`
-option.
-
 String-Slice Objects
 ++++++++++++++++++++
 

pypy/objspace/std/model.py

     "withsmallint"   : ["smallintobject.W_SmallIntObject"],
     "withsmalllong"  : ["smalllongobject.W_SmallLongObject"],
     "withstrslice"   : ["strsliceobject.W_StringSliceObject"],
-    "withstrjoin"    : ["strjoinobject.W_StringJoinObject"],
     "withstrbuf"     : ["strbufobject.W_StringBufferObject"],
     "withtproxy" : ["proxyobject.W_TransparentList",
                     "proxyobject.W_TransparentDict"],
                 (unicodeobject.W_UnicodeObject,
                                        strsliceobject.delegate_slice2unicode),
                 ]
-        if config.objspace.std.withstrjoin:
-            from pypy.objspace.std import strjoinobject
-            self.typeorder[strjoinobject.W_StringJoinObject] += [
-                (stringobject.W_StringObject,
-                                       strjoinobject.delegate_join2str),
-                (unicodeobject.W_UnicodeObject,
-                                       strjoinobject.delegate_join2unicode)
-                ]
-        elif config.objspace.std.withstrbuf:
+        if config.objspace.std.withstrbuf:
             from pypy.objspace.std import strbufobject
             self.typeorder[strbufobject.W_StringBufferObject] += [
                 (stringobject.W_StringObject,

pypy/objspace/std/stringobject.py

         s = input[0] * mul
     else:
         s = input * mul
-    # xxx support again space.config.objspace.std.withstrjoin?
     return W_StringObject(s)
 
 def mul__String_ANY(space, w_str, w_times):

pypy/objspace/std/stringtype.py

     return wrapstr(space, s[start:stop])
 
 def joined2(space, str1, str2):
-    if space.config.objspace.std.withstrjoin:
-        from pypy.objspace.std.strjoinobject import W_StringJoinObject
-        return W_StringJoinObject([str1, str2])
-    elif space.config.objspace.std.withstrbuf:
+    if space.config.objspace.std.withstrbuf:
         from pypy.objspace.std.strbufobject import joined2
         return joined2(str1, str2)
     else:

pypy/objspace/std/strjoinobject.py

-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stringobject import W_AbstractStringObject
-from pypy.objspace.std.stringobject import W_StringObject
-from pypy.objspace.std.unicodeobject import delegate_String2Unicode
-
-from pypy.objspace.std.stringtype import wrapstr
-
-class W_StringJoinObject(W_AbstractStringObject):
-    from pypy.objspace.std.stringtype import str_typedef as typedef
-
-    def __init__(w_self, joined_strs, until=-1):
-        w_self.joined_strs = joined_strs
-        if until == -1:
-            until = len(joined_strs)
-        w_self.until = until
-
-    def force(w_self, always=False):
-        if w_self.until == 1 and not always:
-            return w_self.joined_strs[0]
-        res = "".join(w_self.joined_strs[:w_self.until])
-        w_self.joined_strs = [res]
-        w_self.until = 1
-        return res
-
-    def __repr__(w_self):
-        """ representation for debugging purposes """
-        return "%s(%r, %r)" % (
-            w_self.__class__.__name__, w_self.joined_strs, w_self.until)
-
-    def unwrap(w_self, space):
-        return w_self.force()
-    str_w = unwrap
-
-registerimplementation(W_StringJoinObject)
-
-def delegate_join2str(space, w_strjoin):
-    return wrapstr(space, w_strjoin.force())
-
-def delegate_join2unicode(space, w_strjoin):
-    w_str = wrapstr(space, w_strjoin.force())
-    return delegate_String2Unicode(space, w_str)
-
-def len__StringJoin(space, w_self):
-    result = 0
-    for i in range(w_self.until):
-        result += len(w_self.joined_strs[i])
-    return space.wrap(result)
-
-def add__StringJoin_StringJoin(space, w_self, w_other):
-    if len(w_self.joined_strs) > w_self.until:
-        w_self.force(True)
-    w_self.joined_strs.extend(w_other.joined_strs[:w_other.until])
-    return W_StringJoinObject(w_self.joined_strs)
-
-def add__StringJoin_String(space, w_self, w_other):
-    if len(w_self.joined_strs) > w_self.until:
-        w_self.force(True)
-    other = space.str_w(w_other)
-    w_self.joined_strs.append(other)
-    return W_StringJoinObject(w_self.joined_strs)
-
-def str__StringJoin(space, w_str):
-    # you cannot get subclasses of W_StringObject here
-    assert type(w_str) is W_StringJoinObject
-    return w_str
-
-from pypy.objspace.std import stringtype
-register_all(vars(), stringtype)

pypy/objspace/std/test/test_strjoinobject.py

-from pypy.objspace.std.test import test_stringobject
-
-class AppTestStringObject(test_stringobject.AppTestStringObject):
-    spaceconfig = {"objspace.std.withstrjoin": True}
-
-    def test_basic(self):
-        import __pypy__
-        # cannot do "Hello, " + "World!" because cpy2.5 optimises this
-        # away on AST level (no idea why it doesn't this one)
-        s = "Hello, ".__add__("World!")
-        assert type(s) is str
-        assert 'W_StringJoinObject' in __pypy__.internal_repr(s)
-
-    def test_add_twice(self):
-        x = "a" + ""
-        y = x + "b"
-        c = x + "b"
-        assert c == "ab"
-
-    def test_add(self):
-        import __pypy__
-        all = ""
-        for i in range(20):
-            all += str(i)
-        assert 'W_StringJoinObject' in __pypy__.internal_repr(all)
-
-    def test_hash(self):
-        import __pypy__
-        # check that we have the same hash as CPython for at least 31 bits
-        # (but don't go checking CPython's special case -1)
-        # disabled: assert hash('') == 0 --- different special case
-        def join(s): return s[:len(s) // 2] + s[len(s) // 2:]
-        s = join('a' * 101)
-        assert 'W_StringJoinObject' in __pypy__.internal_repr(s)
-        assert hash(s) & 0x7fffffff == 0x7e0bce58
-
-    def test_len(self):
-        s = "a" + "b"
-        r = "c" + "d"
-        t = s + r
-        assert len(s) == 2
-
-    def test_add_strjoin_strjoin(self):
-        # make three strjoin objects
-        s = 'a' + 'b'
-        t = 'c' + 'd'
-        u = 'e' + 'f'
-
-        # add two different strjoins to the same string
-        v = s + t
-        w = s + u
-
-        # check that insanity hasn't resulted.
-        assert len(v) == len(w) == 4
-
-    def test_more_adding_fun(self):
-        s = 'a' + 'b' # s is a strjoin now
-        t = s + 'c'   # this calls s.force() which sets s.until to 1
-        u = s + 'd'
-        v = s + 'e'
-        assert v == 'abe' # meaning u is abcd
-
-    def test_buh_even_more(self):
-        a = 'a' + 'b'
-        b = a + 'c'
-        c = '0' + '1'
-        x = c + a
-        assert x == '01ab'
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.