> 1. The generated C files #include <Python.h>, which includes a lot of > the system header files --- about 16 500 lines' worth on my system. > gcc can compile a small C source code into a shared library in tens of > milliseconds, but parsing all these header files takes it more than a > second on my 300MHz Pentium.
IIRC from generating Python-callable Bass libraries, python checks a version number passed to Py_InitModule, so you can just hard-code (or snarf what you need from the header files) and be no worse off (for any given installation). The timings I give below imply that a small compile (invoking a shell script + gcc) can be done in well under a second. -Dave :: :: :: C is hard to beat. I though Takeuchi would be a cakewalk after the Fibonacci results, but until I do something with expressions and registers (which would complicate the gdb interface), Bass isn't significantly faster. (and the tail calls in Bass, while making some code easier to write, confuse gprof immensely) pybass.py ========= import sys,os if len(sys.argv) > 1: os.system("bass -so rfmodule.b") import rf print rf.rf(33) > time ./crecfib 33: 3524578 0.59user 0.01system 0:00.59elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (70major+9minor)pagefaults 0swaps > time python pybass.py compile 3524578 0.55user 0.13system 0:00.67elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (2288major+851minor)pagefaults 0swaps > time python pybass.py 3524578 0.30user 0.04system 0:00.33elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (182major+85minor)pagefaults 0swaps :: :: :: > time ./tak 36 24 12 13 363.66user 0.07system 6:08.56elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (73major+9minor)pagefaults 0swaps > time ./tak.b 36 24 12 [compiling] 13 336.41user 0.19system 5:38.27elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (2596major+800minor)pagefaults 0swaps