user1131274
user1131274

Reputation: 473

python memory-profiler giving no attribute error with pickle load

I am trying to use memory_profiler but it is giving pickling error. In my code I am loading a object from a pickle file and the code is working fine but when I am running it with memory profiler it gives "'module' object has no attribute" error. Any suggestions?

Upvotes: 0

Views: 847

Answers (1)

Idl
Idl

Reputation: 39

Use the import mechanism rather than invoking python -m memory_profiler, ie.

from memory_profiler import profile

@profile
def func():
    …
    data = pickle.load(open('myfile', 'rb'))
    …

I’m not able to give a clear explanation of why that works.

Upvotes: 1

Related Questions