]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make readfile read the file in one fell swoop.
authorGuido van Rossum <guido@python.org>
Sun, 21 Oct 1990 16:14:50 +0000 (16:14 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 21 Oct 1990 16:14:50 +0000 (16:14 +0000)
Lib/commands.py

index 145f5dbdc4f59f4d37e882100fb61e607ebdd191..c96953cb9c6460a43d3abcea6cfef10993818e2f 100644 (file)
@@ -4,6 +4,7 @@
 
 import rand
 import posix
+import stat
 import path
 
 
@@ -40,14 +41,7 @@ def getstatusoutput(cmd):
 # Return a string containing a file's contents.
 #
 def readfile(fn):
-       fp = open(fn, 'r')
-       a = ''
-       n = 8096
-       while 1:
-               b = fp.read(n)
-               if not b: break
-               a = a + b
-       return a
+       return open(fn, 'r').read(posix.stat(fn)[stat.ST_SIZE])
 
 
 # Make command argument from directory and pathname (prefix space, add quotes).