0

I can't understand what the {built-in method load} output in cProfile means.

I know that question was already asked but i saw no real answer. I couldn't find out by myself either.

The executed script (Go_IA_vs_IA.py) imports functions from Go_settings.py and use them. You can find them here if it can be any useful for you : https://github.com/Ashargin/Go

Here is what I obtain :

Ordered by: internal time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)

   25    3.793    0.152    3.793    0.152 {built-in method load}
    1    0.071    0.071    3.938    3.938 Go_IA_vs_IA.py:1(<module>)
28481/205    0.027    0.000    0.061    0.000 copy.py:137(deepcopy)
5930/918    0.010    0.000    0.046    0.000 copy.py:215(_deepcopy_list)

... more lines

Obviously I want to optimize that line as it contributes for 96% of the time spent.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Ashargin
  • 498
  • 4
  • 11
  • You're calling ``marshal.load()`` (a built-in function) in several places in Go_settings. If those 25 loads were all different files, then there's not much you can do about this. If it's loading the same file multiple times, you need to retain the data in memory rather than reloading it. – jasonharper Apr 13 '17 at 13:08
  • `load()` function that shows in profiler is in your case [`load()`](https://docs.python.org/2/library/marshal.html) from `marshal` module. In this case it is used to obtain data. You could switch to some other serialization module, try to optimize in a way that only uses load once or just use disc with better response time. – Tomasz Plaskota Apr 13 '17 at 13:09
  • Thanks a lot ! Indeed it is the same file and it was stupid from me not to have though about this alone. – Ashargin Apr 13 '17 at 13:13
  • @jasonharper , @TomaszPlaskota , from the output, how do you know that ``load`` is from the ``marshal`` module? – Charlie Jun 20 '18 at 02:17
  • 1
    @Charlie: by looking at the linked source code. There's no way to tell from the profiler output alone. – jasonharper Jun 20 '18 at 02:47

0 Answers0