view misc.py @ 323:44f94ffe28f7

version works with file and folder, returns null if not in hg. Also a function to get all modules, but seems to get junk at the same time
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Thu, 12 Jun 2008 17:12:45 -0400
parents 9e96fe8b955c
children 430c9e92cd23
line wrap: on
line source


def unique_elements_list_intersection(list1,list2):
    """
    Return the unique elements that are in both list1 and list2
    (repeated elements in listi will not be duplicated in the result).
    This should run in O(n1+n2) where n1=|list1|, n2=|list2|.
    """
    return list(set.intersection(set(list1),set(list2)))
import time
#http://www.daniweb.com/code/snippet368.html
def print_timing(func):
    def wrapper(*arg):
        t1 = time.time()
        res = func(*arg)
        t2 = time.time()
        print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
        return res
    return wrapper