-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use __getstate__ & __setstate__ for deterministic coding
`__getstate__` and `__setstate__` are one of several Python protocols that can be used to implement pickling for a custom type. If the return value from calling `obj.__getstate__()` on a user-provided object is deterministic, then we can use it to deterministically code the object. This provides a low-boilerplate and robust way to make a custom object suitable for use as a key in Beam transforms. Note that we don't need to worry about these protocols in the non-deterministic case, because the fall-back coder already handles these via pickle.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters