Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r59884:a14198d01269
Date: 2013-01-08 18:32 -0800
http://bitbucket.org/pypy/pypy/changeset/a14198d01269/

Log:    significant optimization for TTree iteration

diff --git a/pypy/module/cppyy/capi/cint_capi.py 
b/pypy/module/cppyy/capi/cint_capi.py
--- a/pypy/module/cppyy/capi/cint_capi.py
+++ b/pypy/module/cppyy/capi/cint_capi.py
@@ -153,6 +153,12 @@
     space.call_method(w_branch, "SetStatus", space.wrap(1))
     space.call_method(w_branch, "ResetReadEntry")
 
+c_ttree_GetEntry = rffi.llexternal(
+    "cppyy_ttree_GetEntry",
+    [rffi.VOIDP, rffi.LONGLONG], rffi.LONGLONG,
+    threadsafe=False,
+    compilation_info=eci)
+
 @unwrap_spec(args_w='args_w')
 def ttree_getattr(space, w_self, args_w):
     """Specialized __getattr__ for TTree's that allows switching on/off the
@@ -211,10 +217,9 @@
     def __init__(self, space, w_tree):
         from pypy.module.cppyy import interp_cppyy
         tree = space.interp_w(interp_cppyy.W_CPPInstance, w_tree)
-        self.tree = tree.get_cppthis(tree.cppclass)
+        self.vtree = rffi.cast(rffi.VOIDP, tree.get_cppthis(tree.cppclass))
         self.w_tree = w_tree
 
-        self.getentry = tree.cppclass.get_overload("GetEntry").functions[0]
         self.current  = 0
         self.maxentry = space.int_w(space.call_method(w_tree, 
"GetEntriesFast"))
 
@@ -228,7 +233,7 @@
         if self.current == self.maxentry:
             raise OperationError(self.space.w_StopIteration, self.space.w_None)
         # TODO: check bytes read?
-        self.getentry.call(self.tree, [self.space.wrap(self.current)])
+        c_ttree_GetEntry(self.vtree, self.current)
         self.current += 1 
         return self.w_tree
 
diff --git a/pypy/module/cppyy/include/cintcwrapper.h 
b/pypy/module/cppyy/include/cintcwrapper.h
--- a/pypy/module/cppyy/include/cintcwrapper.h
+++ b/pypy/module/cppyy/include/cintcwrapper.h
@@ -15,6 +15,8 @@
         void* vtree, const char* branchname, const char* classname,
         void* addobj, int bufsize, int splitlevel);
 
+    long long cppyy_ttree_GetEntry(void* vtree, long long entry);
+
 #ifdef __cplusplus
 }
 #endif // ifdef __cplusplus
diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx 
b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -950,3 +950,7 @@
     if (b) b->SetObject(addobj);
     return (cppyy_object_t)b;
 }
+
+long long cppyy_ttree_GetEntry(void* vtree, long long entry) {
+    return (long long)((TTree*)vtree)->GetEntry((Long64_t)entry);
+}
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to