3 ms·
> but pickle expects that every class object will have a reference to it of the same name Yeah: its qualname. The qualname, as per PEP 3155, is defined as: >
by wizzwizz4 5y ago
> but pickle expects that every class object will have a reference to it of the same name
Yeah: its qualname. The qualname, as per PEP 3155, is defined as:
> a dotted path leading to the object from the module top-level
so of course pickle can't cope with this information being incorrect. (How would you make it work?)
- Spivak 5y agoThere’s a difference between the classes __qualname__ and the requirement that there be reference to the class at, say, __main__.$qualname as the way for pickle to actually find the class object. This is the part that, to me, is really odd because pickle knows (in theory) the class and module name of the thing it needs to instantiate and the class objects themselves know their name and module. Up to the lack efficiency actually doing this you could just enumerate all class objects to find the one with the right name and module name. You get nested classes for free this way and you break the requirement that there be references to class objects of the same name in the module.