Changes between Version 1 and Version 2 of Ticket #28444, comment 50

Sep 5, 2019, 3:48:09 AM (3 years ago)
Nils Bruin


  • Ticket #28444, comment 50

    v1 v2  
    55From what I understand, it manages the dictionary in which "constructors" are looked up. A pickle of an object with a `__reduce__` would usually amount to instructions to call a certain named constructor with arguments (encoded in the pickle as well). The name of that constructor needs to be looked up somewhere. If I'm not mistaken, `copyreg` manages the dictionary for that. One can also instantiate `Unpickler` objects (or subclass them) to customize the constructor lookup. In cases where the arguments as pickled would need preprocessing before calling the normal constructor (just class names are generally used as constructors), then it makes sense to register a factory function in place of that class name to do the preprocessing (and then call the relevant class).
     7**EDIT**: I see now that `register_unpickle_override` seems to hook into the same place where `copyreg` for the normal python unpickler goes (sage subclasses the normal unpickler and exposes that via load and loads)
    79> Suggestion: In a ''new'' ticket that will be a dependency for here, I'll change `Matrix_gfpn_dense` so that it will in future use str for pickling and will be able to use both bytes and str for unpickling- Does that make sense to you?