> We have had the occasional bug in SWIG that has been worked around > (particularly in SWIG's iteration over STL types, which has the > unpleasant side effect of occasionally causing access violations). > It's also worth considering the overhead of converting types like > SWBuf to native Python types, since some of the buffers have lots of > text in (not that I'm claiming SWIG is efficient).
I hadn't considered that the overhead would be large, so instead of guessing, I wrote a little test script to time it. The best of 3 runs for each: $ python quick-test-speed.py SWIG SWIG render time: 14.32 $ python quick-test-speed.py SIP SIP render time: 15.90 The script is only loading the KJV module and calling RenderText() on each verse, but at least for this case, the SWIG bindings are 10% faster. Test script attached. Also, I originally wrote the script to increment the module using the += operator; this gave me glibc errors at the end of each run using the SWIG bindings. When I changed the script to use increment(), those errors went away. troy
#!/usr/bin/env python import sys import timeit max_verse = 'Revelation of John 22:21' def test_sword_SIP(): import sword mm = sword.ModuleManager() kjv = mm.getModule('KJV') while kjv.getKey().getText() != max_verse: kjv.renderText() kjv.increment() def test_sword_SWIG(): import Sword mm = Sword.SWMgr() kjv = mm.getModule('KJV') while kjv.getKey().getText() != max_verse: kjv.RenderText() kjv.increment() def usage(): print 'Usage: %s [SWIG|SIP]' % (sys.argv[0], ) if __name__ == '__main__': if len(sys.argv) != 2: usage() else: which = sys.argv[1] if which not in ('SWIG', 'SIP'): usage() else: name = 'test_sword_' + which + '()' imp = 'from __main__ import test_sword_' + which t = timeit.Timer(name, imp) print '%s render time: %2.2f' %(which, t.timeit(number=1))
_______________________________________________ sword-devel mailing list: sword-devel@crosswire.org http://www.crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page