[pypy-svn] r55031 - pypy/branch/hybrid-io/pypy/objspace/std

fijal at codespeak.net fijal at codespeak.net
Tue May 20 18:21:18 CEST 2008


Author: fijal
Date: Tue May 20 18:21:17 2008
New Revision: 55031

Modified:
   pypy/branch/hybrid-io/pypy/objspace/std/formatting.py
   pypy/branch/hybrid-io/pypy/objspace/std/stringobject.py
Log:
Some estimates for formatting.


Modified: pypy/branch/hybrid-io/pypy/objspace/std/formatting.py
==============================================================================
--- pypy/branch/hybrid-io/pypy/objspace/std/formatting.py	(original)
+++ pypy/branch/hybrid-io/pypy/objspace/std/formatting.py	Tue May 20 18:21:17 2008
@@ -256,10 +256,11 @@
             return result
 
         def format(self):
+            lgt = len(self.fmt) + 4 * len(self.values_w) + 10
             if do_unicode:
-                result = UnicodeBuilder()
+                result = UnicodeBuilder(lgt)
             else:
-                result = StringBuilder()
+                result = StringBuilder(lgt)
             self.result = result
             while True:
                 # fast path: consume as many characters as possible

Modified: pypy/branch/hybrid-io/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/hybrid-io/pypy/objspace/std/stringobject.py	(original)
+++ pypy/branch/hybrid-io/pypy/objspace/std/stringobject.py	Tue May 20 18:21:17 2008
@@ -861,7 +861,7 @@
 def repr__String(space, w_str):
     s = w_str._value
 
-    buf = StringBuilder(50) # XXX this needs to be constant, fix
+    buf = StringBuilder(len(s) + 10)
 
     quote = "'"
     if quote in s and '"' not in s:



More information about the Pypy-commit mailing list