Message345797
>Getting the module name from the caller's frame is an expensive operation. It is safe to set __module__ to None. In such case the pickle module is able to find the proper module containing the definition of the class.
Wow, indeed it works. I also tried it from another module other than `__main__` and it works.
Checking the source, I see the "magic" happens in pickle's `whichmodule` function when looping over `sys.modules` if `__module__` is not found. If that case, why check for `__module__` in the first place? wouldn't it be simpler to always loop over sys.modules? Is it to avoid looping over `sys.modules` whenever possible? |
|
Date |
User |
Action |
Args |
2019-06-17 02:46:07 | alegonz | set | recipients:
+ alegonz, steven.daprano, serhiy.storchaka, levkivskyi, abarry |
2019-06-17 02:46:07 | alegonz | set | messageid: <1560739567.27.0.730213589207.issue28869@roundup.psfhosted.org> |
2019-06-17 02:46:07 | alegonz | link | issue28869 messages |
2019-06-17 02:46:07 | alegonz | create | |
|