Shedskin-a python performance optimization tool

Source: Internet
Author: User

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.