imghdr.what(path) return value counts: {None: 15, 'jpeg': 13450, 'tiff': 1695} sum(counts.values()): 15160 386234 function calls (386228 primitive calls) in 2.554 CPU seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 2.554 2.554 :1() 1 0.001 0.001 2.554 2.554 {execfile} 1 0.001 0.001 2.553 2.553 imghdrtest.py:8() 1 0.137 0.137 2.551 2.551 imghdrtest.py:53(main) 15160 0.443 0.000 1.530 0.000 imghdr.py:9(what) 15161 0.292 0.000 0.858 0.000 imghdrtest.py:26(iterFiles) 15160 0.268 0.000 0.268 0.000 {open} 15160 0.246 0.000 0.246 0.000 {method 'read' of 'file' objects} 16053 0.232 0.000 0.232 0.000 {posix.stat} 16046 0.123 0.000 0.182 0.000 posixpath.py:56(join) 15160 0.175 0.000 0.175 0.000 {method 'close' of 'file' objects} 15160 0.059 0.000 0.081 0.000 imghdr.py:51(test_pbm) 16052 0.052 0.000 0.077 0.000 stat.py:54(S_ISREG) 59838 0.068 0.000 0.068 0.000 {len} 15160 0.045 0.000 0.061 0.000 imghdr.py:59(test_pgm) 15160 0.042 0.000 0.057 0.000 imghdr.py:67(test_ppm) 13465 0.039 0.000 0.052 0.000 imghdr.py:89(test_xbm) 892 0.052 0.000 0.052 0.000 {posix.listdir} 15160 0.037 0.000 0.037 0.000 imghdr.py:37(test_rgb) 16050 0.031 0.000 0.031 0.000 {method 'startswith' of 'str' objects} 15160 0.031 0.000 0.031 0.000 imghdr.py:44(test_gif) 15160 0.030 0.000 0.030 0.000 imghdr.py:75(test_tiff) 16046 0.028 0.000 0.028 0.000 {method 'endswith' of 'str' objects} 16944 0.027 0.000 0.027 0.000 stat.py:29(S_IFMT) 15160 0.026 0.000 0.026 0.000 {method 'get' of 'dict' objects} 13465 0.024 0.000 0.024 0.000 imghdr.py:97(test_jpeg) 13465 0.021 0.000 0.021 0.000 imghdr.py:82(test_rast) 892 0.014 0.000 0.014 0.000 {method 'sort' of 'list' objects} 2310 0.004 0.000 0.004 0.000 imghdr.py:104(test_exif) 892 0.003 0.000 0.004 0.000 stat.py:45(S_ISDIR) 892 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() 13 0.000 0.000 0.000 0.000 {issubclass} 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:117(test_png) 15 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 4 0.000 0.000 0.000 0.000 {repr} 8 0.000 0.000 0.000 0.000 {method 'write' of 'cStringIO.StringO' objects} 5 0.000 0.000 0.000 0.000 {getattr} 1 0.000 0.000 0.000 0.000 {sorted} 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:74(__init__) 1 0.000 0.000 0.000 0.000 pprint.py:73(PrettyPrinter) 2 0.000 0.000 0.000 0.000 {cStringIO.StringIO} 2 0.000 0.000 0.000 0.000 {method 'write' of 'file' objects} 1 0.000 0.000 0.000 0.000 {sum} 2 0.000 0.000 0.000 0.000 {method 'getvalue' of 'cStringIO.StringO' objects} 2 0.000 0.000 0.000 0.000 {id} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 1 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 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}