[pypy-commit] pypy remove-string-smm: Remove bytearray.{strip, lstrip, rstrip} multimethods (fijal, hodgestar).
hodgestar
noreply at buildbot.pypy.org
Tue Apr 16 23:06:52 CEST 2013
Author: Simon Cross <hodgestar at gmail.com>
Branch: remove-string-smm
Changeset: r63437:55e0a79ff91d
Date: 2013-04-16 23:06 +0200
http://bitbucket.org/pypy/pypy/changeset/55e0a79ff91d/
Log: Remove bytearray.{strip,lstrip,rstrip} multimethods (fijal,
hodgestar).
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -122,6 +122,27 @@
def descr_reverse(self, space):
self.data.reverse()
+ def descr_strip(self, space, w_chars=None):
+ if space.is_none(w_chars):
+ chars = _space_chars
+ else:
+ chars = space.bufferstr_new_w(w_chars)
+ return _strip(space, self, chars, 1, 1)
+
+ def descr_lstrip(self, space, w_chars=None):
+ if space.is_none(w_chars):
+ chars = _space_chars
+ else:
+ chars = space.bufferstr_new_w(w_chars)
+ return _strip(space, self, chars, 1, 0)
+
+ def descr_rstrip(self, space, w_chars=None):
+ if space.is_none(w_chars):
+ chars = _space_chars
+ else:
+ chars = space.bufferstr_new_w(w_chars)
+ return _strip(space, self, chars, 0, 1)
+
def __repr__(w_self):
""" representation for debugging purposes """
return "%s(%s)" % (w_self.__class__.__name__, ''.join(w_self.data))
@@ -466,23 +487,6 @@
_space_chars = ''.join([chr(c) for c in [9, 10, 11, 12, 13, 32]])
-def bytearray_strip__Bytearray_None(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, _space_chars, 1, 1)
-
-def bytearray_strip__Bytearray_ANY(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 1, 1)
-
-def bytearray_lstrip__Bytearray_None(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, _space_chars, 1, 0)
-
-def bytearray_lstrip__Bytearray_ANY(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 1, 0)
-
-def bytearray_rstrip__Bytearray_None(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, _space_chars, 0, 1)
-
-def bytearray_rstrip__Bytearray_ANY(space, w_bytearray, w_chars):
- return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 0, 1)
# These methods could just delegate to the string implementation,
# but they have to return a bytearray.
diff --git a/pypy/objspace/std/bytearraytype.py b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -92,21 +92,30 @@
"""
raise NotImplementedError
+ def descr_strip(self, space, w_chars=None):
+ """B.strip([bytes]) -> bytearray
-bytearray_strip = SMM('strip', 2, defaults=(None,),
- doc="B.strip([bytes]) -> bytearray\n\nStrip leading "
- "and trailing bytes contained in the argument.\nIf "
- "the argument is omitted, strip ASCII whitespace.")
+ Strip leading and trailing bytes contained in the argument.
+ If the argument is omitted, strip ASCII whitespace.
+ """
+ raise NotImplementedError
-bytearray_lstrip = SMM('lstrip', 2, defaults=(None,),
- doc="B.lstrip([bytes]) -> bytearray\n\nStrip leading "
- "bytes contained in the argument.\nIf the argument is "
- "omitted, strip leading ASCII whitespace.")
+ def descr_lstrip(self, space, w_chars=None):
+ """B.lstrip([bytes]) -> bytearray
-bytearray_rstrip = SMM('rstrip', 2, defaults=(None,),
- doc="'B.rstrip([bytes]) -> bytearray\n\nStrip trailing "
- "bytes contained in the argument.\nIf the argument is "
- "omitted, strip trailing ASCII whitespace.")
+ Strip leading bytes contained in the argument.
+ If the argument is omitted, strip leading ASCII whitespace.
+ """
+ raise NotImplementedError
+
+ def descr_rstrip(self, space, w_chars=None):
+ """B.rstrip([bytes]) -> bytearray
+
+ Strip trailing bytes contained in the argument.
+ If the argument is omitted, strip trailing ASCII whitespace.
+ """
+ raise NotImplementedError
+
def getbytevalue(space, w_value):
if space.isinstance_w(w_value, space.w_str):
@@ -238,5 +247,8 @@
extend=interpindirect2app(W_AbstractBytearrayObject.descr_extend),
join=interpindirect2app(W_AbstractBytearrayObject.descr_join),
reverse=interpindirect2app(W_AbstractBytearrayObject.descr_reverse),
+ strip=interpindirect2app(W_AbstractBytearrayObject.descr_strip),
+ lstrip=interpindirect2app(W_AbstractBytearrayObject.descr_lstrip),
+ rstrip=interpindirect2app(W_AbstractBytearrayObject.descr_rstrip),
)
bytearray_typedef.registermethods(globals())
More information about the pypy-commit
mailing list