Fallback Strategies

The fallback_strategy parameter of the Serializer defines the strategy for dealing with objects that are not pass-through classes or aren’t caught by any hooks. This library offers a few preconfigured strategies as variants of the FallBackStrategy enum:

  • FallBackStrategy.RAISE: raise an error for objects that are not covered otherwise.

  • FallBackStrategy.PASS_THROUGH: treat uncaught objects as pass-through classes.

  • FallBackStrategy.PICKLE_INTERFACE: use catch-all hooks utilizing the pickle interface (see Pickle Fallback Strategy).

Alternatively, serializers can be initialized with a custom pair of fallback catch-all serialization and deserialization hooks, packaged in a HookPair object.