#9 Filter entire packages

open
nobody
None
5
2008-11-07
2008-11-07
Jason Heeris
No

It would good if I could stop Psyco from trying to optimise any function under a particular packages (in my case, Cheetah). Since the filter function only looks at code objects, which have no context information, this seems to be presently impossible. Alternatively, it would be good if there was an option to stop the optimisation of functions only called by other functions which have been passed to 'cannotcompile.'

Discussion

  • Armin Rigo
    Armin Rigo
    2008-11-07

    I will not fix this (Psyco is only in "maintenance" mode nowadays), but I can suggest a few ideas to do it: a quick hack would be to look at the code object's co_filename in the filter function.

    Alternatively, you can try not using psyco.full() or psyco.profile() at all, but only psyco.bind() and psyco.cannotcompile(). If you bind() an entry point function, it should recursively optimize all the functions that this entry point calls, stopping at functions marked cannotcompile(). You may have to pass a larger value to the 'rec' argument, if the default is not enough (the default is to stop recursing after 10 levels).

     
  • Armin Rigo
    Armin Rigo
    2008-11-07

    I will not fix this (Psyco is only in "maintenance" mode nowadays), but I can suggest a few ideas to do it: a quick hack would be to look at the code object's co_filename in the filter function.

    Alternatively, you can try not using psyco.full() or psyco.profile() at all, but only psyco.bind() and psyco.cannotcompile(). If you bind() an entry point function, it should recursively optimize all the functions that this entry point calls, stopping at functions marked cannotcompile(). You may have to pass a larger value to the 'rec' argument, if the default is not enough (the default is to stop recursing after 10 levels).

     
  • Jason Heeris
    Jason Heeris
    2008-11-09

    Ah, I didn't realise that Psyco would stop at functions marked with 'cannotcompile()' — there's a note in the docs (3.1):

    "Note that this does not prevent functions called by object to be compiled, if they are bound or proxied or if the profiler chooses to compile them."

    The problem is that Psyco seems to have problems with the Cheetah templating engine (which compiles html templates into python scripts), but I don't really have the time to get to the bottom of it (I doubt it would be a trivial task). It might be worth doing as you say and finding entry points to mark.