Mercurial > pylearn
comparison misc.py @ 231:38beb81f4e8b
Automated merge with ssh://projects@lgcm.iro.umontreal.ca/hg/pylearn
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Tue, 27 May 2008 13:46:03 -0400 |
parents | d7250ee86f72 |
children | 9e96fe8b955c |
comparison
equal
deleted
inserted
replaced
227:17c5d080964b | 231:38beb81f4e8b |
---|---|
25 Return the unique elements that are in both list1 and list2 | 25 Return the unique elements that are in both list1 and list2 |
26 (repeated elements in listi will not be duplicated in the result). | 26 (repeated elements in listi will not be duplicated in the result). |
27 This should run in O(n1+n2) where n1=|list1|, n2=|list2|. | 27 This should run in O(n1+n2) where n1=|list1|, n2=|list2|. |
28 """ | 28 """ |
29 return list(set.intersection(set(list1),set(list2))) | 29 return list(set.intersection(set(list1),set(list2))) |
30 import time | |
31 #http://www.daniweb.com/code/snippet368.html | |
32 def print_timing(func): | |
33 def wrapper(*arg): | |
34 t1 = time.time() | |
35 res = func(*arg) | |
36 t2 = time.time() | |
37 print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0) | |
38 return res | |
39 return wrapper |