Why not always use psyco for Python code?

前端 未结 8 542
北恋
北恋 2020-12-13 06:29

psyco seems to be quite helpful in optimizing Python code, and it does it in a very non-intrusive way.

Therefore, one has to wonder. Assuming you\'re always on a x8

相关标签:
8条回答
  • 2020-12-13 06:42

    Quite simply: "Because the code already runs fast enough".

    0 讨论(0)
  • 2020-12-13 06:44

    One should never rely on some magic bullet to fix your problems. Using psyco to make a slow program faster is usually not necessary. Bad algorithms can be rewritten, and parts that require speed could be written in another language. Of course, your question asks why we don't use it for the speed boost anyways, and there's a bit of overhead when you use psyco. Psyco uses memory, and those two lines just sorta feel like overhead when you look at them. As for my personal reason on why I don't use psyco, it's because it doesn't support x86_64, which I see as the new up and coming architecture (especially with 2038 approaching sooner or later). My alternative is pypy, but I'm not entirely fond of that either.

    0 讨论(0)
  • 2020-12-13 06:46

    psyco is dead and not longer maintained. It is time to find another

    0 讨论(0)
  • 2020-12-13 06:48

    It also depends where your bottleneck is. I am mostly doing web apps and there the bottlenecks are probably more IO and database. So you should know where to optimize.

    Also beware that maybe you first should think about your code instead of directly throwing psyco at it. So I agree with Devin, that algorithm optimizations should come first and they might have a smaller chance of unwanted sideeffects.

    0 讨论(0)
  • 2020-12-13 06:53

    Psyco currently uses a lot of memory. It only runs on Intel 386-compatible processors (under any OS) right now. There are some subtle semantic differences (i.e. bugs) with the way Python works; they should not be apparent in most programs.

    See also the caveats section. For a hard example, I noticed that my web app with Cheetah-generated templates and DB I/O gained no appreciable speedup.

    0 讨论(0)
  • 2020-12-13 06:54

    A couple of other things:

    1. It doesn't seem to be very actively maintained.
    2. It can be a memory hog.
    0 讨论(0)
提交回复
热议问题