[pypy-commit] pypy numpy-data-buffer: simple implementation of fromfile.

timo_jbo noreply at buildbot.pypy.org
Mon Oct 3 17:11:06 CEST 2011


Author: Timo Paulssen <timonator at perpetuum-immobile.de>
Branch: numpy-data-buffer
Changeset: r47796:60161adfdbba
Date: 2011-10-03 17:01 +0200
http://bitbucket.org/pypy/pypy/changeset/60161adfdbba/

Log:	simple implementation of fromfile.

diff --git a/lib_pypy/numpy/__init__.py b/lib_pypy/numpy/__init__.py
--- a/lib_pypy/numpy/__init__.py
+++ b/lib_pypy/numpy/__init__.py
@@ -136,3 +136,7 @@
 
     return __from_buffer_or_datastring(s, dtype, count)
 
+def fromfile(file, dtype=float, count=-1, sep=''):
+    if isinstance(file, basestring):
+        file = open(file, "r")
+    return fromstring(file.read(), dtype, count, sep)


More information about the pypy-commit mailing list