pprofile icon indicating copy to clipboard operation
pprofile copied to clipboard

Unexpected behavior with built-in iterators

Open lozanodorian opened this issue 7 months ago • 1 comments

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?

lozanodorian avatar Jul 01 '24 15:07 lozanodorian