>>> cProfile.run('descendants(doc)') 1272715 function calls in 3.057 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 1.768 1.768 3.053 3.053 :1(descendants) 1 0.004 0.004 3.057 3.057 :1() 489505 0.512 0.000 0.616 0.000 pxdom.py:214(__getattr__) 97901 0.061 0.000 0.079 0.000 pxdom.py:279(__len__) 195801 0.090 0.000 0.090 0.000 pxdom.py:282(__getitem__) 97901 0.035 0.000 0.035 0.000 pxdom.py:946(_get_childNodes) 97901 0.069 0.000 0.069 0.000 {getattr} 97901 0.017 0.000 0.017 0.000 {len} 97901 0.018 0.000 0.018 0.000 {method 'append' of 'list' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 97901 0.482 0.000 0.482 0.000 {method 'pop' of 'list' objects} >>> cProfile.run('descendent(doc)') 783208 function calls (685308 primitive calls) in 1.467 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 97901/1 0.993 0.000 1.464 1.464 :1(descendent) 1 0.004 0.004 1.467 1.467 :1() 195802 0.251 0.000 0.356 0.000 pxdom.py:214(__getattr__) 195801 0.089 0.000 0.089 0.000 pxdom.py:282(__getitem__) 97901 0.035 0.000 0.035 0.000 pxdom.py:946(_get_childNodes) 97901 0.070 0.000 0.070 0.000 {getattr} 97900 0.026 0.000 0.026 0.000 {method 'append' of 'list' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}