pprofile
pprofile copied to clipboard
Unexpected behavior with built-in iterators
Probably a silly remark, but we couldn't explain this behavior with my team.
When we profile a loop with a built-in iterator, e.g.:
for _ in range(10 ** 7):
pass
The result is:
Line #| Hits| Time| Time per hit| %|Source code
------+----------+-------------+-------------+-------+-----------
1| 0| 0| 0| 0.00%|for _ in range(10 ** 7):
2| 20| 0| 0| 0.00%| pass
i.e. that line 1 does not have any hit, while a pass
has all the hits, which seems quite surprising. Do you know if this is normal?