#NEWLINE# def sort_compare( a , n ) : #NEWLINE# #INDENT# print ( ( 'Dict sort of %d items for %d iterations:' % ( len ( a ) , n ) ) ) #NEWLINE# t1 = time . time ( ) #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# b = sortedDictValues3 ( a ) #NEWLINE# #UNINDENT# t2 = time . time ( ) #NEWLINE# py = ( t2 - t1 ) #NEWLINE# print ( ' speed in python:' , ( t2 - t1 ) ) #NEWLINE# print ( b [ : 5 ] ) #NEWLINE# b = c_sort ( a ) #NEWLINE# t1 = time . time ( ) #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# b = c_sort ( i ) #NEWLINE# #UNINDENT# t2 = time . time ( ) #NEWLINE# print ( ' speed in c (Python API):' , ( t2 - t1 ) ) #NEWLINE# print ( ( ' speed up: %3.2f' % ( py / ( t2 - t1 ) ) ) ) #NEWLINE# print ( b [ : 5 ] ) #NEWLINE# b = c_sort2 ( a ) #NEWLINE# t1 = time . time ( ) #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# b = c_sort2 ( a ) #NEWLINE# #UNINDENT# t2 = time . time ( ) #NEWLINE# print ( ' speed in c (scxx):' , ( t2 - t1 ) ) #NEWLINE# print ( ( ' speed up: %3.2f' % ( py / ( t2 - t1 ) ) ) ) #NEWLINE# print ( b [ : 5 ] )