[pypy-svn] r72581 - pypy/trunk/pypy/module/cpyext

afa at codespeak.net afa at codespeak.net
Mon Mar 22 18:17:07 CET 2010


Author: afa
Date: Mon Mar 22 18:17:05 2010
New Revision: 72581

Modified:
   pypy/trunk/pypy/module/cpyext/stringobject.py
Log:
rffi has a nice function for PyString_FromStringAndSize(), use it


Modified: pypy/trunk/pypy/module/cpyext/stringobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/stringobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/stringobject.py	Mon Mar 22 18:17:05 2010
@@ -3,13 +3,8 @@
 
 @cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
 def PyString_FromStringAndSize(space, char_p, length):
-    l = []
-    i = 0
-    while length > 0:
-        l.append(char_p[i])
-        i += 1
-        length -= 1
-    return space.wrap("".join(l))
+    s = rffi.charpsize2str(char_p, length)
+    return space.wrap(s)
 
 @cpython_api([rffi.CCHARP], PyObject)
 def PyString_FromString(space, char_p):



More information about the Pypy-commit mailing list