Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Psyco Decorator (See related posts)

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 ...

You need to create an account or log in to post comments to this site.