Mercurial > pylearn
diff misc.py @ 355:430c9e92cd23
Added common directory
author | Joseph Turian <turian@iro.umontreal.ca> |
---|---|
date | Thu, 19 Jun 2008 16:12:29 -0400 |
parents | 9e96fe8b955c |
children |
line wrap: on
line diff
--- a/misc.py Thu Jun 19 12:35:41 2008 -0400 +++ b/misc.py Thu Jun 19 16:12:29 2008 -0400 @@ -1,18 +0,0 @@ - -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