Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r59167:ae4392b65d8c
Date: 2012-12-01 10:09 -0800
http://bitbucket.org/pypy/pypy/changeset/ae4392b65d8c/
Log: Remove unused strjoin option
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -228,9 +228,6 @@
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),
@@ -372,7 +369,6 @@
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)
diff --git a/pypy/doc/config/objspace.std.withstrjoin.txt
b/pypy/doc/config/objspace.std.withstrjoin.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.withstrjoin.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Enable "string join" objects.
-
-See the page about `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`:
../interpreter-optimizations.html#string-join-objects
-
-
diff --git a/pypy/doc/interpreter-optimizations.rst
b/pypy/doc/interpreter-optimizations.rst
--- a/pypy/doc/interpreter-optimizations.rst
+++ b/pypy/doc/interpreter-optimizations.rst
@@ -34,19 +34,6 @@
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
++++++++++++++++++++
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -20,7 +20,6 @@
"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"],
@@ -229,15 +228,7 @@
(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,
diff --git a/pypy/objspace/std/stringobject.py
b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -912,7 +912,6 @@
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):
diff --git a/pypy/objspace/std/stringtype.py b/pypy/objspace/std/stringtype.py
--- a/pypy/objspace/std/stringtype.py
+++ b/pypy/objspace/std/stringtype.py
@@ -45,10 +45,7 @@
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:
diff --git a/pypy/objspace/std/strjoinobject.py
b/pypy/objspace/std/strjoinobject.py
deleted file mode 100644
--- a/pypy/objspace/std/strjoinobject.py
+++ /dev/null
@@ -1,69 +0,0 @@
-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)
diff --git a/pypy/objspace/std/test/test_strjoinobject.py
b/pypy/objspace/std/test/test_strjoinobject.py
deleted file mode 100644
--- a/pypy/objspace/std/test/test_strjoinobject.py
+++ /dev/null
@@ -1,69 +0,0 @@
-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'
-
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit