cloudpipe / cloudpipe/cloudpickle

Support for pickling functions within a class defined outside of __main__?

Offen
#175 6 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Python
Sterne
1.9k
Forks
195
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
1

Beschreibung

Cloudpickle's ability to serialize instantiated classes and their member functions is a huge advantage over cloudpickle alternatives. Unfortunately, this feature seems limited heavily to the check for `instantiated_class.__module__ == '__main__'`.

One hacky solution is to set `__module__` in the class definition:
```
class SomeFunClass(object):
__module__ = '__main__'

# Rest of the class definition
```

But this could cause problems with any code that relies on a proper value for `__module__`. Is there another solution I'm not seeing?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.