[pypy-svn] r56099 - pypy/dist/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Thu Jun 26 22:50:34 CEST 2008


Author: fijal
Date: Thu Jun 26 22:50:32 2008
New Revision: 56099

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rffi.py
Log:
Cache results and don't invoke gcc over and over again


Modified: pypy/dist/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rffi.py	Thu Jun 26 22:50:32 2008
@@ -379,10 +379,14 @@
         hints = hints.copy()
     hints['external'] = 'C'
     hints['c_name'] = name
-    def lazy_getsize():
+    def lazy_getsize(cache={}):
         from pypy.rpython.tool import rffi_platform
-        k = {}
-        return rffi_platform.sizeof(name, compilation_info)
+        try:
+            return cache[name]
+        except KeyError:
+            val = rffi_platform.sizeof(name, compilation_info)
+            cache[name] = val
+            return val
     
     hints['getsize'] = lazy_getsize
     return lltype.OpaqueType(name, hints)



More information about the Pypy-commit mailing list