
Hi Alex,
Okay, with respect to the SWIG + pypy, works for me, and about 4x slower then cppyy or cpython ( which show same results more or less).
I'll try the SWIG portion later (as well as all the other points that you raise in this thread; I think the feedback is great). First, I now have the PyObject* tests (whew!) and that has allowed me to push the code. Also, I found one reason why my micro-benchmark was so slow: the objects were all kept alive (ref counting problem), meaning the number of objects to keep track of by cpyext kept growing, thus the lookups became slower and slower. The tests caught that. :) With that solved, micro-bench speeds are okay-ish. Then, rewriting your example to use PyObject* directly, there is one problem: the C++ side now needs an additional Py_IncRef (which is a function call, not a macro, in PyPy, adding extra overhead) since it takes ownership. Keeping the python objects alive on the python side does not work as well, since e.g. ints are apparently not pinned down, like I thought earlier, so you may get a fresh one with the same value on the C++ side. Note that if you use the typedef ref_t, a selection file is needed to tell Reflex about that typedef, or no binding will be generated for it. Alternative, you can use PyObject* directly (which is also a typedef, but I hard-coded that name in cppyy, together with the actual _object, for convenience). Okay, so speeds ... It's not too bad. As discussed before, your method and the cpyext one are mostly the same, so similar should be expected, and it is: CPPYY Created container No more items real 0m2.013s user 0m1.931s sys 0m0.073s Cpython Created container No more items real 0m2.722s user 0m2.556s sys 0m0.157s I then tried with the fast path enabled, but clearly all the time is being spent in cpyext, so I although it does show consistent better timings, the difference is only 0.02 secs. Maybe that could be faster, but cpyext is an impressive piece of work, quite a bit above my PyPy-skills. :} Overall, I'm happy enough with the result (I'm going to need handling of PyObject*'s later for my own nefarious purposes). Best regards, Wim -- WLavrijsen@lbl.gov -- +1 (510) 486 6411 -- www.lavrijsen.net