[pypy-commit] pypy default: Use newlist_bytes() in posix.listdir() to save some allocations

alex_gaynor noreply at buildbot.pypy.org
Mon Jun 30 20:58:31 CEST 2014


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r72297:e3c95427844d
Date: 2014-06-30 11:57 -0700
http://bitbucket.org/pypy/pypy/changeset/e3c95427844d/

Log:	Use newlist_bytes() in posix.listdir() to save some allocations

diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -578,13 +578,13 @@
                 except OperationError, e:
                     # fall back to the original byte string
                     result_w[i] = w_bytes
+            return space.newlist(result_w)
         else:
             dirname = space.str0_w(w_dirname)
             result = rposix.listdir(dirname)
-            result_w = [space.wrap(s) for s in result]
+            return space.newlist_bytes(result)
     except OSError, e:
         raise wrap_oserror2(space, e, w_dirname)
-    return space.newlist(result_w)
 
 def pipe(space):
     "Create a pipe.  Returns (read_end, write_end)."


More information about the pypy-commit mailing list