imghdr.what(path) return value counts: {None: 15, 'jpeg': 13450, 'tiff': 1695} sum(counts.values()): 15160 228228 function calls (228222 primitive calls) in 2.010 CPU seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 2.010 2.010 :1() 1 0.001 0.001 2.010 2.010 {execfile} 1 0.001 0.001 2.008 2.008 imghdrtest.py:8() 1 0.137 0.137 2.007 2.007 imghdrtest.py:53(main) 15160 0.245 0.000 0.997 0.000 imghdr.py:9(what) 15161 0.291 0.000 0.846 0.000 imghdrtest.py:26(iterFiles) 15160 0.259 0.000 0.259 0.000 {open} 15160 0.241 0.000 0.241 0.000 {method 'read' of 'file' objects} 16053 0.227 0.000 0.227 0.000 {posix.stat} 16046 0.123 0.000 0.181 0.000 posixpath.py:56(join) 15160 0.170 0.000 0.170 0.000 {method 'close' of 'file' objects} 16052 0.052 0.000 0.076 0.000 stat.py:54(S_ISREG) 892 0.050 0.000 0.050 0.000 {posix.listdir} 15160 0.041 0.000 0.041 0.000 imghdr.py:97(test_jpeg) 16050 0.031 0.000 0.031 0.000 {method 'startswith' of 'str' objects} 16046 0.028 0.000 0.028 0.000 {method 'endswith' of 'str' objects} 15160 0.026 0.000 0.026 0.000 {method 'get' of 'dict' objects} 16944 0.026 0.000 0.026 0.000 stat.py:29(S_IFMT) 892 0.011 0.000 0.011 0.000 {method 'sort' of 'list' objects} 1710 0.007 0.000 0.010 0.000 imghdr.py:51(test_pbm) 6038 0.008 0.000 0.008 0.000 {len} 1710 0.005 0.000 0.007 0.000 imghdr.py:59(test_pgm) 1710 0.005 0.000 0.007 0.000 imghdr.py:67(test_ppm) 4005 0.006 0.000 0.006 0.000 imghdr.py:104(test_exif) 1710 0.004 0.000 0.004 0.000 imghdr.py:75(test_tiff) 1710 0.004 0.000 0.004 0.000 imghdr.py:44(test_gif) 892 0.003 0.000 0.004 0.000 stat.py:45(S_ISDIR) 1710 0.003 0.000 0.003 0.000 imghdr.py:37(test_rgb) 894 0.002 0.000 0.002 0.000 {method 'insert' of 'list' objects} 893 0.002 0.000 0.002 0.000 {iter} 1 0.001 0.001 0.001 0.001 pprint.py:35() 1 0.000 0.000 0.000 0.000 pprint.py:51(pprint) 1 0.000 0.000 0.000 0.000 pprint.py:105(pprint) 1 0.000 0.000 0.000 0.000 pprint.py:121(_format) 1 0.000 0.000 0.000 0.000 pprint.py:193(_repr) 1 0.000 0.000 0.000 0.000 pprint.py:202(format) 7/1 0.000 0.000 0.000 0.000 pprint.py:212(_safe_repr) 1 0.000 0.000 0.000 0.000 imghdr.py:1() 15 0.000 0.000 0.000 0.000 imghdr.py:89(test_xbm) 13 0.000 0.000 0.000 0.000 {issubclass} 15 0.000 0.000 0.000 0.000 imghdr.py:117(test_png) 15 0.000 0.000 0.000 0.000 imghdr.py:111(test_bmp) 15 0.000 0.000 0.000 0.000 imghdr.py:82(test_rast) 15 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 8 0.000 0.000 0.000 0.000 {method 'write' of 'cStringIO.StringO' objects} 4 0.000 0.000 0.000 0.000 {repr} 5 0.000 0.000 0.000 0.000 {getattr} 1 0.000 0.000 0.000 0.000 {sorted} 1 0.000 0.000 0.000 0.000 pprint.py:74(__init__) 8 0.000 0.000 0.000 0.000 {method 'isalpha' of 'str' objects} 1 0.000 0.000 0.000 0.000 pprint.py:73(PrettyPrinter) 2 0.000 0.000 0.000 0.000 {method 'remove' of 'list' objects} 2 0.000 0.000 0.000 0.000 {method 'write' of 'file' objects} 2 0.000 0.000 0.000 0.000 {cStringIO.StringIO} 2 0.000 0.000 0.000 0.000 {method 'getvalue' of 'cStringIO.StringO' objects} 1 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 1 0.000 0.000 0.000 0.000 {sum} 2 0.000 0.000 0.000 0.000 {id} 1 0.000 0.000 0.000 0.000 {method 'copy' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'values' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}