Shedskin http://code.google.com/p/shedskin/
Although python's performance is still outstanding in the scripting language, when the for, while loop, or function recursive call occurs in the program, its performance decreases very quickly.
For example, it takes only a few milliseconds for the C language to calculate fibonacci (33) using a recursive method, but python takes about 10 seconds.
Currently, some tools have been used to optimize python performance, such as psyco, which can achieve JIT optimization.
Shedskin adopts a new method, namely, "Translation ". It translates the python code into C ++, and then compiles it into the pyd (in windows) And so (in * nix) modules. In this way, other python code can easily import compiled modules, which is very efficient and convenient.
After I re-compile the recursive solution's fibonacci function with shedskin, the speed is basically the same as that of the C language version.
PS:
It is found that the version of shedskin in FreeBSD has a small bug-The lpcre library cannot be found when Makefile is generated.
You need to make some modifications to the ss. py file:
If sys. platform = 'darwin' and OS. path. isdir ('/usr/local/include '):
Line + = '-I/usr/local/include' # XXX
....
If sys. platform = 'darwin' and OS. path. isdir ('/usr/local/lib'): # XXX
Line + = '-L/usr/local/lib'
....
SYS. Platform = 'darwin.
Shedskin also has its disadvantage, that is, it can only be translated using the python standard library.SubsetPython Program (table below ):
Bisect
Collections
Configparser
Copy
Datetime
Fnmatch
Getopt
Glob
Math
OS (some functionality missing under Windows)
OS. Path
Random
Re
Socket
String
Sys
Time