[Scipy-svn] r4658 - in branches/fast_vectorize: . mkufunc

scipy-svn@scip... scipy-svn@scip...
Tue Aug 19 19:35:59 CDT 2008


Author: ilan
Date: 2008-08-19 19:35:58 -0500 (Tue, 19 Aug 2008)
New Revision: 4658

Removed:
   branches/fast_vectorize/mkufunc/func_hash.py
Modified:
   branches/fast_vectorize/README.txt
   branches/fast_vectorize/TODO.txt
   branches/fast_vectorize/mkufunc/fast_vectorize.py
Log:
Merged function hash into fast_vectorize.py, updated TODO list,
and added things to the README file.


Modified: branches/fast_vectorize/README.txt
===================================================================
--- branches/fast_vectorize/README.txt	2008-08-19 23:53:07 UTC (rev 4657)
+++ branches/fast_vectorize/README.txt	2008-08-20 00:35:58 UTC (rev 4658)
@@ -1,6 +1,8 @@
+==============
+fast_vectorize
+==============
 
-mkufunc (make universal function) is a tool which lets you create
-a C compiled version of a universal function (UFunc).
+fast_vectorize lets you create U functions from python source code.
 
 It works by translating the python function into C and then uses
 scipy.weave to create a UFunc which calls the appropriate C function
@@ -10,10 +12,11 @@
 are very large).
 
 Requirements:
-
   pypy
 
-You need the pypy path in your PYTHONPATH environment:
 
-$ export PYTHONPATH=/<...>/pypy-dist
+Use SVN to download the pypy source:
+svn co http://codespeak.net/svn/pypy/dist pypy-dist
 
+Make sure pypy can be imported, e.g. set your PYTHONPATH:
+export PYTHONPATH=<path-to-pypy-dist>

Modified: branches/fast_vectorize/TODO.txt
===================================================================
--- branches/fast_vectorize/TODO.txt	2008-08-19 23:53:07 UTC (rev 4657)
+++ branches/fast_vectorize/TODO.txt	2008-08-20 00:35:58 UTC (rev 4658)
@@ -1,9 +1,5 @@
 
-- Documentation
+* Documentation
 
-- think about shipping issues (using weave ext_tools)
+* think about shipping issues (using weave ext_tools)
 
-- add Csrc attribute to ufunc object
-
-- see if monkeypatch of pypy modules is feasible/desired
-

Modified: branches/fast_vectorize/mkufunc/fast_vectorize.py
===================================================================
--- branches/fast_vectorize/mkufunc/fast_vectorize.py	2008-08-19 23:53:07 UTC (rev 4657)
+++ branches/fast_vectorize/mkufunc/fast_vectorize.py	2008-08-20 00:35:58 UTC (rev 4658)
@@ -3,19 +3,16 @@
 Author: Ilan Schnell
 Thanks: Travis Oliphant and Eric Jones
 """
-import sys
 import re
 import os
 import cStringIO
-from types import FunctionType
+import md5
+from types import CodeType, FunctionType
 
 import numpy
 from scipy import weave
 
-# Local imports
-from func_hash import func_hash
 
-
 _verbose = 0
 _showc = 0
 _force = 0
@@ -51,6 +48,34 @@
     return str(t.driver.cbuilder.c_source_filename)
 
 
+def func_hash(f, salt=None):
+    """
+    Return a MD5 hash for a function or code object as hexadecimal string.
+    """
+    if type(f) == FunctionType:
+        co = f.func_code
+    elif type(f) == CodeType:
+        co = f
+    else:
+        raise TypeError("Object %r is not function or code object.")
+    
+    res = []
+    for name in dir(co):
+        if not name.startswith('co_'):
+            continue
+        if name == 'co_consts':
+            for c in getattr(co, name):
+                if type(c) == CodeType or \
+                   type(c) == FunctionType:
+                    res.append(func_hash(c))
+                else:
+                    res.append(repr(c))
+        else:
+            res.append(repr(getattr(co, name)))
+            
+    return md5.md5(''.join(res) + repr(salt)).hexdigest()
+
+
 def translate_cached(f, argtypes):
     """
     Return pypy's C output for a given function and argument types

Deleted: branches/fast_vectorize/mkufunc/func_hash.py
===================================================================
--- branches/fast_vectorize/mkufunc/func_hash.py	2008-08-19 23:53:07 UTC (rev 4657)
+++ branches/fast_vectorize/mkufunc/func_hash.py	2008-08-20 00:35:58 UTC (rev 4658)
@@ -1,29 +0,0 @@
-import md5
-from types import CodeType, FunctionType
-
-
-def func_hash(f, salt=None):
-    """ Return a MD5 hash for a function or code object as string.
-    """
-    if type(f) == FunctionType:
-        co = f.func_code
-    elif type(f) == CodeType:
-        co = f
-    else:
-        raise TypeError("Object %r is not function or code object.")
-    
-    res = []
-    for name in dir(co):
-        if not name.startswith('co_'):
-            continue
-        if name == 'co_consts':
-            for c in getattr(co, name):
-                if type(c) == CodeType or \
-                   type(c) == FunctionType:
-                    res.append(func_hash(c))
-                else:
-                    res.append(repr(c))
-        else:
-            res.append(repr(getattr(co, name)))
-            
-    return md5.md5(''.join(res) + repr(salt)).hexdigest()



More information about the Scipy-svn mailing list