« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Psyco Decorator

This will cause decorated functions to be run using the psyco optimizer. It will allow the code to continue working even if psyco is not available

Decorator:
try:
    import psyco
except:
    pass

def optimize(func):
    try:
        return psyco.proxy(func)
    except:
        return func


Usage:
@optimize
def complex_function(n):
    ... do complex stuff with n ...
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed