Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r46073:7982de091965
Date: 2011-07-28 15:39 -0700
http://bitbucket.org/pypy/pypy/changeset/7982de091965/
Log: Preallocate the result for str.__repr__ more appropriately, use
len(self) + 2, which will be correct in the common case of "no
special characgters".
Alex
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
@@ -913,7 +913,7 @@
def repr__String(space, w_str):
s = w_str._value
- buf = StringBuilder(50)
+ buf = StringBuilder(len(s) + 2)
quote = "'"
if quote in s and '"' not in s:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit