Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r66686:99bad40100ae
Date: 2013-08-30 14:49 -0700
http://bitbucket.org/pypy/pypy/changeset/99bad40100ae/
Log: Marked str.title() as elidable
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
@@ -230,13 +230,13 @@
return space.wrap(builder.build())
-def str_title__String(space, w_self):
- input = w_self._value
- builder = StringBuilder(len(input))
+
[email protected]
+def title(s):
+ builder = StringBuilder(len(s))
prev_letter = ' '
- for pos in range(len(input)):
- ch = input[pos]
+ for ch in s:
if not prev_letter.isalpha():
ch = _upper(ch)
builder.append(ch)
@@ -245,8 +245,12 @@
builder.append(ch)
prev_letter = ch
+ return builder.build()
- return space.wrap(builder.build())
+
+def str_title__String(space, w_self):
+ return space.wrap(title(w_self._value))
+
def str_split__String_None_ANY(space, w_self, w_none, w_maxsplit=-1):
maxsplit = space.int_w(w_maxsplit)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit