tsar2512
tsar2512

Reputation: 2994

Interpreting Memory Profiling results in Python

I am trying to understand how memory_profiler works in python especially in the context of for loops. In particular, as you can see the increment column here shows negative usage, which I cannot understand.

Can anyone explain the memory profile of this snippet?

The following snapshot shows a memory profile of a python code snippet:

   290 602.2148437500 MiB -53838.4804687500 MiB           for fname in self.foo.bar:
   291 602.2148437500 MiB -53460.6132812500 MiB               if fname.endswith('html'):
   292 602.7109375000 MiB -9612.6601562500 MiB                   soup = BeautifulSoup(self.foo.bar_dict[fname],'html.parser')
   294 602.7187500000 MiB -9629.5312500000 MiB                   self._process_links(soup, fname)

Upvotes: 1

Views: 266

Answers (1)

Fabian Pedregosa
Fabian Pedregosa

Reputation: 6539

The output on loops is the maximum of the times that line was executed. The second line should show the diff with respect to the previous line, but this is obviously wrong in this case.

Upvotes: 1

Related Questions